Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / Darwin / dump_registers.cpp
blobcc2710f062d89e07c2ac314c7e71678345357e64
1 // Check that ASan dumps the CPU registers on a SIGSEGV.
3 // RUN: %clangxx_asan %s -o %t
4 // RUN: not %run %t 2>&1 | FileCheck %s
6 #include <assert.h>
7 #include <stdio.h>
8 #include <sys/mman.h>
10 int main() {
11 fprintf(stderr, "Hello\n");
12 char *ptr;
14 ptr = (char *)mmap(NULL, 0x10000, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
15 assert(ptr && "failed to mmap");
17 fprintf(stderr, sizeof(uintptr_t) == 8 ? "p = 0x%016lx\n" : "p = 0x%08lx\n", (uintptr_t)ptr);
18 // CHECK: p = [[ADDR:0x[0-9]+]]
20 char c = *ptr; // BOOM
21 // CHECK: ERROR: AddressSanitizer: {{SEGV|BUS}}
22 // CHECK: Register values:
23 // CHECK: [[ADDR]]
24 fprintf(stderr, "World\n");
25 return c;