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