Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / cfi / stats.cpp
blobca6b3bf0df48146ef03932eb0d9f04899b66a167
1 // RUN: %clangxx_cfi %debug_info_flags -fsanitize-stats -o %t %s
2 // RUN: env SANITIZER_STATS_PATH=%t.stats %run %t
3 // RUN: sanstats %t.stats | FileCheck %s
5 // FIXME: We currently emit the wrong debug info under devirtualization.
6 // UNSUPPORTED: devirt
8 // FIXME: %t.stats must be transferred from device to host for this to work on Android.
9 // XFAIL: android
11 struct ABase {};
13 struct A : ABase {
14 virtual void vf() {}
15 void nvf() {}
18 extern "C" __attribute__((noinline)) void vcall(A *a) {
19 // CHECK: stats.cpp:[[@LINE+1]] {{_?}}vcall cfi-vcall 37
20 a->vf();
23 extern "C" __attribute__((noinline)) void nvcall(A *a) {
24 // CHECK: stats.cpp:[[@LINE+1]] {{_?}}nvcall cfi-nvcall 51
25 a->nvf();
28 extern "C" __attribute__((noinline)) A *dcast(A *a) {
29 // CHECK: stats.cpp:[[@LINE+1]] {{_?}}dcast cfi-derived-cast 24
30 return (A *)(ABase *)a;
33 extern "C" __attribute__((noinline)) A *ucast(A *a) {
34 // CHECK: stats.cpp:[[@LINE+1]] {{_?}}ucast cfi-unrelated-cast 81
35 return (A *)(char *)a;
38 extern "C" __attribute__((noinline)) void unreachable(A *a) {
39 // CHECK-NOT: unreachable
40 a->vf();
43 int main() {
44 A a;
45 for (unsigned i = 0; i != 37; ++i)
46 vcall(&a);
47 for (unsigned i = 0; i != 51; ++i)
48 nvcall(&a);
49 for (unsigned i = 0; i != 24; ++i)
50 dcast(&a);
51 for (unsigned i = 0; i != 81; ++i)
52 ucast(&a);
53 for (unsigned i = 0; i != 0; ++i)
54 unreachable(&a);