Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -fsanitize=thread %s | FileCheck %s
      2 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -O1 %s | FileCheck %s
      3 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -O1  -relaxed-aliasing -fsanitize=thread %s | FileCheck %s
      4 //
      5 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s --check-prefix=NOTBAA
      6 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -O2  -relaxed-aliasing %s | FileCheck %s --check-prefix=NOTBAA
      7 //
      8 // Check that we generate TBAA for vtable pointer loads and stores.
      9 // When -fsanitize=thread is used TBAA should be generated at all opt levels
     10 // even if -relaxed-aliasing is present.
     11 struct A {
     12   virtual int foo() const ;
     13   virtual ~A();
     14 };
     15 
     16 void CreateA() {
     17   new A;
     18 }
     19 
     20 void CallFoo(A *a, int (A::*fp)() const) {
     21   a->foo();
     22   (a->*fp)();
     23 }
     24 
     25 // CHECK-LABEL: @_Z7CallFoo
     26 // CHECK: %{{.*}} = load {{.*}} !tbaa ![[NUM:[0-9]+]]
     27 // CHECK: br i1
     28 // CHECK: load {{.*}}, !tbaa ![[NUM]]
     29 //
     30 // CHECK-LABEL: @_ZN1AC2Ev
     31 // CHECK: store {{.*}} !tbaa ![[NUM]]
     32 //
     33 // CHECK: [[NUM]] = !{[[TYPE:!.*]], [[TYPE]], i64 0}
     34 // CHECK: [[TYPE]] = !{!"vtable pointer", !{{.*}}
     35 // NOTBAA-NOT: = !{!"Simple C++ TBAA"}
     36