1 ; RUN: opt < %s -passes=tsan -S | FileCheck --check-prefixes=CHECK,CHECK-OPT %s
2 ; RUN: opt < %s -passes=tsan -tsan-instrument-read-before-write -S | FileCheck %s --check-prefixes=CHECK,CHECK-UNOPT
3 ; RUN: opt < %s -passes=tsan -tsan-compound-read-before-write -S | FileCheck %s --check-prefixes=CHECK,CHECK-COMPOUND
4 ; RUN: opt < %s -passes=tsan -tsan-distinguish-volatile -tsan-compound-read-before-write -S | FileCheck %s --check-prefixes=CHECK,CHECK-COMPOUND-VOLATILE
6 target 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"
8 define void @IncrementMe(ptr nocapture %ptr) nounwind uwtable sanitize_thread {
10 %0 = load i32, ptr %ptr, align 4
11 %inc = add nsw i32 %0, 1
12 store i32 %inc, ptr %ptr, align 4
15 ; CHECK-LABEL: define void @IncrementMe
16 ; CHECK-OPT-NOT: __tsan_read4
17 ; CHECK-COMPOUND-NOT: __tsan_read4
18 ; CHECK-UNOPT: __tsan_read4
19 ; CHECK-OPT: __tsan_write4
20 ; CHECK-UNOPT: __tsan_write4
21 ; CHECK-COMPOUND: __tsan_read_write4
24 define void @IncrementMeWithCallInBetween(ptr nocapture %ptr) nounwind uwtable sanitize_thread {
26 %0 = load i32, ptr %ptr, align 4
27 %inc = add nsw i32 %0, 1
29 store i32 %inc, ptr %ptr, align 4
33 ; CHECK-LABEL: define void @IncrementMeWithCallInBetween
35 ; CHECK: __tsan_write4
40 define void @VolatileLoad(ptr nocapture %ptr) nounwind uwtable sanitize_thread {
42 %0 = load volatile i32, ptr %ptr, align 4
43 %inc = add nsw i32 %0, 1
44 store i32 %inc, ptr %ptr, align 4
47 ; CHECK-LABEL: define void @VolatileLoad
48 ; CHECK-COMPOUND-NOT: __tsan_read4
49 ; CHECK-COMPOUND-VOLATILE: __tsan_volatile_read4
50 ; CHECK-COMPOUND: __tsan_read_write4
51 ; CHECK-COMPOUND-VOLATILE: __tsan_write4
54 define void @VolatileStore(ptr nocapture %ptr) nounwind uwtable sanitize_thread {
56 %0 = load i32, ptr %ptr, align 4
57 %inc = add nsw i32 %0, 1
58 store volatile i32 %inc, ptr %ptr, align 4
61 ; CHECK-LABEL: define void @VolatileStore
62 ; CHECK-COMPOUND-NOT: __tsan_read4
63 ; CHECK-COMPOUND-VOLATILE: __tsan_read4
64 ; CHECK-COMPOUND: __tsan_read_write4
65 ; CHECK-COMPOUND-VOLATILE: __tsan_volatile_write4
68 define void @VolatileBoth(ptr nocapture %ptr) nounwind uwtable sanitize_thread {
70 %0 = load volatile i32, ptr %ptr, align 4
71 %inc = add nsw i32 %0, 1
72 store volatile i32 %inc, ptr %ptr, align 4
75 ; CHECK-LABEL: define void @VolatileBoth
76 ; CHECK-COMPOUND-NOT: __tsan_read4
77 ; CHECK-COMPOUND-VOLATILE: __tsan_volatile_read4
78 ; CHECK-COMPOUND: __tsan_read_write4
79 ; CHECK-COMPOUND-VOLATILE: __tsan_volatile_write4