1// RUN: %clangxx_hwasan -fomit-frame-pointer -momit-leaf-frame-pointer \
2// RUN: -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
3// RUN: %clangxx_hwasan -fomit-frame-pointer -momit-leaf-frame-pointer \
4// RUN: -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
5// RUN: %clangxx_hwasan -fomit-frame-pointer -momit-leaf-frame-pointer \
6// RUN: -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
7// RUN: %clangxx_hwasan -fomit-frame-pointer -momit-leaf-frame-pointer \
8// RUN: -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
9
10// This test ensures that the CFA is implemented properly for slow
11// (non-frame-pointer) unwinding.
12#include <sanitizer/hwasan_interface.h>
13#include <stdio.h>
14#include <stdlib.h>
15
16__attribute__((noinline)) void f(int *p) { *p = 3; }
17
18// CHECK: ERROR: HWAddressSanitizer:
19// CHECK: #{{[0-9]}} {{.*}} in f(int*) {{.*}}register-dump-no-fp.cpp:[[@LINE-3]]
20
21int main() {
22 __hwasan_enable_allocator_tagging();
23
24 int *volatile a = new int;
25 a = (int *)__hwasan_tag_pointer(p: a, tag: 0);
26 f(p: a);
27 // CHECK: #{{[0-9]}} {{.*}} in main {{.*}}register-dump-no-fp.cpp:[[@LINE-1]]
28}
29

source code of compiler-rt/test/hwasan/TestCases/register-dump-no-fp.cpp