1 ; RUN: opt < %s -passes=tsan -tsan-distinguish-volatile -S | FileCheck %s
3 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"
5 define i16 @test_volatile_read2(ptr %a) sanitize_thread {
7 %tmp1 = load volatile i16, ptr %a, align 2
11 ; CHECK-LABEL: define i16 @test_volatile_read2(ptr %a)
12 ; CHECK: call void @__tsan_func_entry(ptr %0)
13 ; CHECK-NEXT: call void @__tsan_volatile_read2(ptr %a)
14 ; CHECK-NEXT: %tmp1 = load volatile i16, ptr %a, align 2
15 ; CHECK-NEXT: call void @__tsan_func_exit()
18 define i32 @test_volatile_read4(ptr %a) sanitize_thread {
20 %tmp1 = load volatile i32, ptr %a, align 4
24 ; CHECK-LABEL: define i32 @test_volatile_read4(ptr %a)
25 ; CHECK: call void @__tsan_func_entry(ptr %0)
26 ; CHECK-NEXT: call void @__tsan_volatile_read4(ptr %a)
27 ; CHECK-NEXT: %tmp1 = load volatile i32, ptr %a, align 4
28 ; CHECK-NEXT: call void @__tsan_func_exit()
31 define i64 @test_volatile_read8(ptr %a) sanitize_thread {
33 %tmp1 = load volatile i64, ptr %a, align 8
37 ; CHECK-LABEL: define i64 @test_volatile_read8(ptr %a)
38 ; CHECK: call void @__tsan_func_entry(ptr %0)
39 ; CHECK-NEXT: call void @__tsan_volatile_read8(ptr %a)
40 ; CHECK-NEXT: %tmp1 = load volatile i64, ptr %a, align 8
41 ; CHECK-NEXT: call void @__tsan_func_exit()
44 define i128 @test_volatile_read16(ptr %a) sanitize_thread {
46 %tmp1 = load volatile i128, ptr %a, align 16
50 ; CHECK-LABEL: define i128 @test_volatile_read16(ptr %a)
51 ; CHECK: call void @__tsan_func_entry(ptr %0)
52 ; CHECK-NEXT: call void @__tsan_volatile_read16(ptr %a)
53 ; CHECK-NEXT: %tmp1 = load volatile i128, ptr %a, align 16
54 ; CHECK-NEXT: call void @__tsan_func_exit()
57 define void @test_volatile_write2(ptr %a) sanitize_thread {
59 store volatile i16 1, ptr %a, align 2
63 ; CHECK-LABEL: define void @test_volatile_write2(ptr %a)
64 ; CHECK: call void @__tsan_func_entry(ptr %0)
65 ; CHECK-NEXT: call void @__tsan_volatile_write2(ptr %a)
66 ; CHECK-NEXT: store volatile i16 1, ptr %a, align 2
67 ; CHECK-NEXT: call void @__tsan_func_exit()
70 define void @test_volatile_write4(ptr %a) sanitize_thread {
72 store volatile i32 1, ptr %a, align 4
76 ; CHECK-LABEL: define void @test_volatile_write4(ptr %a)
77 ; CHECK: call void @__tsan_func_entry(ptr %0)
78 ; CHECK-NEXT: call void @__tsan_volatile_write4(ptr %a)
79 ; CHECK-NEXT: store volatile i32 1, ptr %a, align 4
80 ; CHECK-NEXT: call void @__tsan_func_exit()
83 define void @test_volatile_write8(ptr %a) sanitize_thread {
85 store volatile i64 1, ptr %a, align 8
89 ; CHECK-LABEL: define void @test_volatile_write8(ptr %a)
90 ; CHECK: call void @__tsan_func_entry(ptr %0)
91 ; CHECK-NEXT: call void @__tsan_volatile_write8(ptr %a)
92 ; CHECK-NEXT: store volatile i64 1, ptr %a, align 8
93 ; CHECK-NEXT: call void @__tsan_func_exit()
96 define void @test_volatile_write16(ptr %a) sanitize_thread {
98 store volatile i128 1, ptr %a, align 16
102 ; CHECK-LABEL: define void @test_volatile_write16(ptr %a)
103 ; CHECK: call void @__tsan_func_entry(ptr %0)
104 ; CHECK-NEXT: call void @__tsan_volatile_write16(ptr %a)
105 ; CHECK-NEXT: store volatile i128 1, ptr %a, align 16
106 ; CHECK-NEXT: call void @__tsan_func_exit()
109 ; Check unaligned volatile accesses
111 define i32 @test_unaligned_read4(ptr %a) sanitize_thread {
113 %tmp1 = load volatile i32, ptr %a, align 2
117 ; CHECK-LABEL: define i32 @test_unaligned_read4(ptr %a)
118 ; CHECK: call void @__tsan_func_entry(ptr %0)
119 ; CHECK-NEXT: call void @__tsan_unaligned_volatile_read4(ptr %a)
120 ; CHECK-NEXT: %tmp1 = load volatile i32, ptr %a, align 2
121 ; CHECK-NEXT: call void @__tsan_func_exit()
124 define void @test_unaligned_write4(ptr %a) sanitize_thread {
126 store volatile i32 1, ptr %a, align 1
130 ; CHECK-LABEL: define void @test_unaligned_write4(ptr %a)
131 ; CHECK: call void @__tsan_func_entry(ptr %0)
132 ; CHECK-NEXT: call void @__tsan_unaligned_volatile_write4(ptr %a)
133 ; CHECK-NEXT: store volatile i32 1, ptr %a, align 1
134 ; CHECK-NEXT: call void @__tsan_func_exit()
137 ; Check that regular aligned accesses are unaffected
139 define i32 @test_read4(ptr %a) sanitize_thread {
141 %tmp1 = load i32, ptr %a, align 4
145 ; CHECK-LABEL: define i32 @test_read4(ptr %a)
146 ; CHECK: call void @__tsan_func_entry(ptr %0)
147 ; CHECK-NEXT: call void @__tsan_read4(ptr %a)
148 ; CHECK-NEXT: %tmp1 = load i32, ptr %a, align 4
149 ; CHECK-NEXT: call void @__tsan_func_exit()
152 define void @test_write4(ptr %a) sanitize_thread {
154 store i32 1, ptr %a, align 4
158 ; CHECK-LABEL: define void @test_write4(ptr %a)
159 ; CHECK: call void @__tsan_func_entry(ptr %0)
160 ; CHECK-NEXT: call void @__tsan_write4(ptr %a)
161 ; CHECK-NEXT: store i32 1, ptr %a, align 4
162 ; CHECK-NEXT: call void @__tsan_func_exit()