blob: 93690361906b6f501501c6ad274d529c841cbd5f [file] [log] [blame]
Richard Smithd6396a62012-11-05 22:21:05 +00001// RUN: %clang_cc1 -emit-llvm -o - -O0 -fsanitize=thread %s | FileCheck %s
Kostya Serebryany8cb4a072012-03-26 17:03:51 +00002// RUN: %clang_cc1 -emit-llvm -o - -O1 %s | FileCheck %s
Richard Smithd6396a62012-11-05 22:21:05 +00003// RUN: %clang_cc1 -emit-llvm -o - -O1 -relaxed-aliasing -fsanitize=thread %s | FileCheck %s
Kostya Serebryanyc9fe6052012-04-24 06:57:01 +00004//
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 Serebryany8cb4a072012-03-26 17:03:51 +00008// Check that we generate TBAA for vtable pointer loads and stores.
Kostya Serebryanyc9fe6052012-04-24 06:57:01 +00009// When -fthread-sanitizer is used TBAA should be generated at all opt levels
10// even if -relaxed-aliasing is present.
Kostya Serebryany8cb4a072012-03-26 17:03:51 +000011struct A {
12 virtual int foo() const ;
13 virtual ~A();
14};
15
16void CreateA() {
17 new A;
18}
19
20void CallFoo(A *a) {
21 a->foo();
22}
23
Kostya Serebryany58197502012-10-01 08:39:00 +000024// CHECK: %{{.*}} = load {{.*}} !tbaa ![[NUM:[0-9]+]]
25// CHECK: store {{.*}} !tbaa ![[NUM]]
26// CHECK: [[NUM]] = metadata !{metadata !"vtable pointer", metadata !{{.*}}}
Kostya Serebryanyc9fe6052012-04-24 06:57:01 +000027// NOTBAA-NOT: = metadata !{metadata !"Simple C/C++ TBAA"}