| 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 %s | FileCheck %s --check-prefixes=CHECK,OLD-PATH |
| 3 | // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - -O1 -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 %s | FileCheck %s --check-prefixes=CHECK,NEW-PATH |
| 7 | // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -new-struct-path-tbaa -o - -O1 -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 -relaxed-aliasing %s | FileCheck %s --check-prefix=NOTBAA |
| 11 | // |
| 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(); |
| 18 | }; |
| 19 | |
| 20 | void CreateA() { |
| 21 | new A; |
| 22 | } |
| 23 | |
| 24 | void CallFoo(A *a, int (A::*fp)() const) { |
| 25 | a->foo(); |
| 26 | (a->*fp)(); |
| 27 | } |
| 28 | |
| 29 | // CHECK-LABEL: @_Z7CallFoo |
| 30 | // CHECK: %{{.*}} = load i32 (%struct.A*)**, {{.*}} !tbaa ![[NUM:[0-9]+]] |
| 31 | // CHECK: br i1 |
| 32 | // CHECK: load i8*, {{.*}}, !tbaa ![[NUM]] |
| 33 | // |
| 34 | // CHECK-LABEL: @_ZN1AC2Ev |
| 35 | // CHECK: store i32 (...)** {{.*}}, !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 | |