brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 9d8c2ee Raw
66 lines · cpp
1// RUN: %clangxx_cfi_dso -DSHARED_LIB -fPIC -g -fsanitize-stats -shared -o %t.so %s2// RUN: %clangxx_cfi_dso -g -fsanitize-stats -o %t %s %t.so3// RUN: env SANITIZER_STATS_PATH=%t.stats %t4// RUN: sanstats %t.stats | FileCheck %s5 6// CFI-icall is not implemented in thinlto mode => ".cfi" suffixes are missing7// in sanstats output.8 9// FIXME: %t.stats must be transferred from device to host for this to work on Android.10// XFAIL: android11 12struct ABase {};13 14struct A : ABase {15  virtual void vf() {}16  void nvf() {}17};18 19extern "C" void vcall(A *a);20extern "C" void nvcall(A *a);21 22#ifdef SHARED_LIB23 24extern "C" __attribute__((noinline)) void vcall(A *a) {25  // CHECK-DAG: stats.cpp:[[@LINE+1]] vcall.cfi cfi-vcall 3726  a->vf();27}28 29extern "C" __attribute__((noinline)) void nvcall(A *a) {30  // CHECK-DAG: stats.cpp:[[@LINE+1]] nvcall.cfi cfi-nvcall 5131  a->nvf();32}33 34#else35 36extern "C" __attribute__((noinline)) A *dcast(A *a) {37  // CHECK-DAG: stats.cpp:[[@LINE+1]] dcast.cfi cfi-derived-cast 2438  return (A *)(ABase *)a;39}40 41extern "C" __attribute__((noinline)) A *ucast(A *a) {42  // CHECK-DAG: stats.cpp:[[@LINE+1]] ucast.cfi cfi-unrelated-cast 8143  return (A *)(char *)a;44}45 46extern "C" __attribute__((noinline)) void unreachable(A *a) {47  // CHECK-NOT: unreachable48  a->vf();49}50 51int main() {52  A a;53  for (unsigned i = 0; i != 37; ++i)54    vcall(&a);55  for (unsigned i = 0; i != 51; ++i)56    nvcall(&a);57  for (unsigned i = 0; i != 24; ++i)58    dcast(&a);59  for (unsigned i = 0; i != 81; ++i)60    ucast(&a);61  for (unsigned i = 0; i != 0; ++i)62    unreachable(&a);63}64 65#endif66