Richard Smith | d6396a6 | 2012-11-05 22:21:05 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -o - -O0 -fsanitize=thread %s | FileCheck %s |
Kostya Serebryany | 8cb4a07 | 2012-03-26 17:03:51 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -emit-llvm -o - -O1 %s | FileCheck %s |
Richard Smith | d6396a6 | 2012-11-05 22:21:05 +0000 | [diff] [blame] | 3 | // RUN: %clang_cc1 -emit-llvm -o - -O1 -relaxed-aliasing -fsanitize=thread %s | FileCheck %s |
Kostya Serebryany | c9fe605 | 2012-04-24 06:57:01 +0000 | [diff] [blame] | 4 | // |
| 5 | // RUN: %clang_cc1 -emit-llvm -o - -O0 %s | FileCheck %s --check-prefix=NOTBAA |
| 6 | // RUN: %clang_cc1 -emit-llvm -o - -O2 -relaxed-aliasing %s | FileCheck %s --check-prefix=NOTBAA |
| 7 | // |
Kostya Serebryany | 8cb4a07 | 2012-03-26 17:03:51 +0000 | [diff] [blame] | 8 | // Check that we generate TBAA for vtable pointer loads and stores. |
Kostya Serebryany | c9fe605 | 2012-04-24 06:57:01 +0000 | [diff] [blame] | 9 | // When -fthread-sanitizer is used TBAA should be generated at all opt levels |
| 10 | // even if -relaxed-aliasing is present. |
Kostya Serebryany | 8cb4a07 | 2012-03-26 17:03:51 +0000 | [diff] [blame] | 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) { |
| 21 | a->foo(); |
| 22 | } |
| 23 | |
Kostya Serebryany | 5819750 | 2012-10-01 08:39:00 +0000 | [diff] [blame] | 24 | // CHECK: %{{.*}} = load {{.*}} !tbaa ![[NUM:[0-9]+]] |
| 25 | // CHECK: store {{.*}} !tbaa ![[NUM]] |
| 26 | // CHECK: [[NUM]] = metadata !{metadata !"vtable pointer", metadata !{{.*}}} |
Kostya Serebryany | c9fe605 | 2012-04-24 06:57:01 +0000 | [diff] [blame] | 27 | // NOTBAA-NOT: = metadata !{metadata !"Simple C/C++ TBAA"} |