xref: /aosp_15_r20/external/llvm/test/Instrumentation/ThreadSanitizer/vptr_update.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -tsan -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; Check that vtable pointer updates are treated in a special way.
3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Workerdefine void @Foo(i8** nocapture %a, i8* %b) nounwind uwtable sanitize_thread {
6*9880d681SAndroid Build Coastguard Workerentry:
7*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @Foo
8*9880d681SAndroid Build Coastguard Worker; CHECK: call void @__tsan_vptr_update
9*9880d681SAndroid Build Coastguard Worker; CHECK: ret void
10*9880d681SAndroid Build Coastguard Worker  store i8* %b, i8** %a, align 8, !tbaa !0
11*9880d681SAndroid Build Coastguard Worker  ret void
12*9880d681SAndroid Build Coastguard Worker}
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerdefine void @FooInt(i64* nocapture %a, i64 %b) nounwind uwtable sanitize_thread {
15*9880d681SAndroid Build Coastguard Workerentry:
16*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @FooInt
17*9880d681SAndroid Build Coastguard Worker; CHECK: call void @__tsan_vptr_update
18*9880d681SAndroid Build Coastguard Worker; CHECK: ret void
19*9880d681SAndroid Build Coastguard Worker  store i64 %b, i64* %a, align 8, !tbaa !0
20*9880d681SAndroid Build Coastguard Worker  ret void
21*9880d681SAndroid Build Coastguard Worker}
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Workerdeclare i32 @Func1()
25*9880d681SAndroid Build Coastguard Workerdeclare i32 @Func2()
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Worker; Test that we properly handle vector stores marked as vtable updates.
28*9880d681SAndroid Build Coastguard Workerdefine void @VectorVptrUpdate(<2 x i8*>* nocapture %a, i8* %b) nounwind uwtable sanitize_thread {
29*9880d681SAndroid Build Coastguard Workerentry:
30*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @VectorVptrUpdate
31*9880d681SAndroid Build Coastguard Worker; CHECK: call void @__tsan_vptr_update{{.*}}Func1
32*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: call void @__tsan_vptr_update
33*9880d681SAndroid Build Coastguard Worker; CHECK: ret void
34*9880d681SAndroid Build Coastguard Worker  store <2 x i8 *> <i8* bitcast(i32 ()* @Func1 to i8 *), i8* bitcast(i32 ()* @Func2 to i8 *)>,  <2 x i8 *>* %a, align 8, !tbaa !0
35*9880d681SAndroid Build Coastguard Worker  ret void
36*9880d681SAndroid Build Coastguard Worker}
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Worker!0 = !{!2, !2, i64 0}
39*9880d681SAndroid Build Coastguard Worker!1 = !{!"Simple C/C++ TBAA", null}
40*9880d681SAndroid Build Coastguard Worker!2 = !{!"vtable pointer", !1}
41