Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / tbaa-for-vptr.cpp
blobbaa93f5efd70fc61ea96006915979fad20877715
1 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -fsanitize=thread %s | FileCheck %s --check-prefixes=CHECK,OLD-PATH
2 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -O1 -fno-inline %s | FileCheck %s --check-prefixes=CHECK,OLD-PATH
3 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -O1 -fno-inline -relaxed-aliasing -fsanitize=thread %s | FileCheck %s --check-prefixes=CHECK,OLD-PATH
4 //
5 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -new-struct-path-tbaa -o - -fsanitize=thread %s | FileCheck %s --check-prefixes=CHECK,NEW-PATH
6 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -new-struct-path-tbaa -o - -O1 -fno-inline %s | FileCheck %s --check-prefixes=CHECK,NEW-PATH
7 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -new-struct-path-tbaa -o - -O1 -fno-inline -relaxed-aliasing -fsanitize=thread %s | FileCheck %s --check-prefixes=CHECK,NEW-PATH
8 //
9 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s --check-prefix=NOTBAA
10 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -O2 -fno-inline -relaxed-aliasing %s | FileCheck %s --check-prefix=NOTBAA
12 // Check that we generate TBAA for vtable pointer loads and stores.
13 // When -fsanitize=thread is used TBAA should be generated at all opt levels
14 // even if -relaxed-aliasing is present.
15 struct A {
16 virtual int foo() const ;
17 virtual ~A();
20 void CreateA() {
21 new A;
24 void CallFoo(A *a, int (A::*fp)() const) {
25 a->foo();
26 (a->*fp)();
29 // CHECK-LABEL: @_Z7CallFoo
30 // CHECK: %{{.*}} = load ptr, {{.*}} !tbaa ![[NUM:[0-9]+]]
31 // CHECK: br i1
32 // CHECK: load ptr, {{.*}}, !tbaa ![[NUM]]
34 // CHECK-LABEL: @_ZN1AC2Ev
35 // CHECK: store ptr {{.*}}, !tbaa ![[NUM]]
37 // OLD-PATH: [[NUM]] = !{[[TYPE:!.*]], [[TYPE]], i64 0}
38 // OLD-PATH: [[TYPE]] = !{!"vtable pointer", !{{.*}}
39 // NEW-PATH: [[NUM]] = !{[[TYPE:!.*]], [[TYPE]], i64 0, i64 [[POINTER_SIZE:.*]]}
40 // NEW-PATH: [[TYPE]] = !{!{{.*}}, i64 [[POINTER_SIZE]], !"vtable pointer"}
41 // NOTBAA-NOT: = !{!"Simple C++ TBAA"}