42 lines · cpp
1// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -fsanitize=thread %s | FileCheck %s --check-prefixes=CHECK,OLD-PATH2// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -O1 -fno-inline %s | FileCheck %s --check-prefixes=CHECK,OLD-PATH3// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -O1 -fno-inline -relaxed-aliasing -fsanitize=thread %s | FileCheck %s --check-prefixes=CHECK,OLD-PATH4//5// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -new-struct-path-tbaa -o - -fsanitize=thread %s | FileCheck %s --check-prefixes=CHECK,NEW-PATH6// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -new-struct-path-tbaa -o - -O1 -fno-inline %s | FileCheck %s --check-prefixes=CHECK,NEW-PATH7// 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-PATH8//9// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s --check-prefix=NOTBAA10// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -O2 -fno-inline -relaxed-aliasing %s | FileCheck %s --check-prefix=NOTBAA11//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 levels14// even if -relaxed-aliasing is present.15struct A {16 virtual int foo() const ;17 virtual ~A();18};19 20void CreateA() {21 new A;22}23 24void CallFoo(A *a, int (A::*fp)() const) {25 a->foo();26 (a->*fp)();27}28 29// CHECK-LABEL: @_Z7CallFoo30// CHECK: %{{.*}} = load ptr, {{.*}} !tbaa ![[NUM:[0-9]+]]31// CHECK: br i132// CHECK: load ptr, {{.*}}, !tbaa ![[NUM]]33//34// CHECK-LABEL: @_ZN1AC2Ev35// CHECK: store ptr {{.*}}, !tbaa ![[NUM]]36//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"}42