0d9ac8e1fd1ebdddcef0d3a025d1be19a314ae21
[oota-llvm.git] / test / Instrumentation / MemorySanitizer / msan_basic.ll
1 ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
2 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK-ORIGINS %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"
4
5 ; Check the presence of __msan_init
6 ; CHECK: @llvm.global_ctors {{.*}} @__msan_init
7
8 ; Check the presence and the linkage type of __msan_track_origins and
9 ; other interface symbols.
10 ; CHECK: @__msan_track_origins = weak_odr constant i32 0
11 ; CHECK: @__msan_keep_going = weak_odr constant i32 0
12 ; CHECK: @__msan_retval_tls = external thread_local(initialexec) global [{{.*}}]
13 ; CHECK: @__msan_retval_origin_tls = external thread_local(initialexec) global i32
14 ; CHECK: @__msan_param_tls = external thread_local(initialexec) global [{{.*}}]
15 ; CHECK: @__msan_param_origin_tls = external thread_local(initialexec) global [{{.*}}]
16 ; CHECK: @__msan_va_arg_tls = external thread_local(initialexec) global [{{.*}}]
17 ; CHECK: @__msan_va_arg_overflow_size_tls = external thread_local(initialexec) global i64
18 ; CHECK: @__msan_origin_tls = external thread_local(initialexec) global i32
19
20
21 ; Check instrumentation of stores
22
23 define void @Store(i32* nocapture %p, i32 %x) nounwind uwtable sanitize_memory {
24 entry:
25   store i32 %x, i32* %p, align 4
26   ret void
27 }
28
29 ; CHECK: @Store
30 ; CHECK: load {{.*}} @__msan_param_tls
31 ; CHECK: store
32 ; CHECK: store
33 ; CHECK: ret void
34 ; CHECK-ORIGINS: @Store
35 ; CHECK-ORIGINS: load {{.*}} @__msan_param_tls
36 ; CHECK-ORIGINS: store
37 ; CHECK-ORIGINS: icmp
38 ; CHECK-ORIGINS: br i1
39 ; CHECK-ORIGINS: <label>
40 ; CHECK-ORIGINS: store
41 ; CHECK-ORIGINS: br label
42 ; CHECK-ORIGINS: <label>
43 ; CHECK-ORIGINS: store
44 ; CHECK-ORIGINS: ret void
45
46
47 ; Check instrumentation of aligned stores
48 ; Shadow store has the same alignment as the original store; origin store
49 ; does not specify explicit alignment.
50
51 define void @AlignedStore(i32* nocapture %p, i32 %x) nounwind uwtable sanitize_memory {
52 entry:
53   store i32 %x, i32* %p, align 32
54   ret void
55 }
56
57 ; CHECK: @AlignedStore
58 ; CHECK: load {{.*}} @__msan_param_tls
59 ; CHECK: store {{.*}} align 32
60 ; CHECK: store {{.*}} align 32
61 ; CHECK: ret void
62 ; CHECK-ORIGINS: @AlignedStore
63 ; CHECK-ORIGINS: load {{.*}} @__msan_param_tls
64 ; CHECK-ORIGINS: store {{.*}} align 32
65 ; CHECK-ORIGINS: icmp
66 ; CHECK-ORIGINS: br i1
67 ; CHECK-ORIGINS: <label>
68 ; CHECK-ORIGINS: store {{.*}} align 32
69 ; CHECK-ORIGINS: br label
70 ; CHECK-ORIGINS: <label>
71 ; CHECK-ORIGINS: store {{.*}} align 32
72 ; CHECK-ORIGINS: ret void
73
74
75 ; load followed by cmp: check that we load the shadow and call __msan_warning.
76 define void @LoadAndCmp(i32* nocapture %a) nounwind uwtable sanitize_memory {
77 entry:
78   %0 = load i32* %a, align 4
79   %tobool = icmp eq i32 %0, 0
80   br i1 %tobool, label %if.end, label %if.then
81
82 if.then:                                          ; preds = %entry
83   tail call void (...)* @foo() nounwind
84   br label %if.end
85
86 if.end:                                           ; preds = %entry, %if.then
87   ret void
88 }
89
90 declare void @foo(...)
91
92 ; CHECK: @LoadAndCmp
93 ; CHECK: = load
94 ; CHECK: = load
95 ; CHECK: call void @__msan_warning_noreturn()
96 ; CHECK-NEXT: call void asm sideeffect
97 ; CHECK-NEXT: unreachable
98 ; CHECK: ret void
99
100 ; Check that we store the shadow for the retval.
101 define i32 @ReturnInt() nounwind uwtable readnone sanitize_memory {
102 entry:
103   ret i32 123
104 }
105
106 ; CHECK: @ReturnInt
107 ; CHECK: store i32 0,{{.*}}__msan_retval_tls
108 ; CHECK: ret i32
109
110 ; Check that we get the shadow for the retval.
111 define void @CopyRetVal(i32* nocapture %a) nounwind uwtable sanitize_memory {
112 entry:
113   %call = tail call i32 @ReturnInt() nounwind
114   store i32 %call, i32* %a, align 4
115   ret void
116 }
117
118 ; CHECK: @CopyRetVal
119 ; CHECK: load{{.*}}__msan_retval_tls
120 ; CHECK: store
121 ; CHECK: store
122 ; CHECK: ret void
123
124
125 ; Check that we generate PHIs for shadow.
126 define void @FuncWithPhi(i32* nocapture %a, i32* %b, i32* nocapture %c) nounwind uwtable sanitize_memory {
127 entry:
128   %tobool = icmp eq i32* %b, null
129   br i1 %tobool, label %if.else, label %if.then
130
131   if.then:                                          ; preds = %entry
132   %0 = load i32* %b, align 4
133   br label %if.end
134
135   if.else:                                          ; preds = %entry
136   %1 = load i32* %c, align 4
137   br label %if.end
138
139   if.end:                                           ; preds = %if.else, %if.then
140   %t.0 = phi i32 [ %0, %if.then ], [ %1, %if.else ]
141   store i32 %t.0, i32* %a, align 4
142   ret void
143 }
144
145 ; CHECK: @FuncWithPhi
146 ; CHECK: = phi
147 ; CHECK-NEXT: = phi
148 ; CHECK: store
149 ; CHECK: store
150 ; CHECK: ret void
151
152 ; Compute shadow for "x << 10"
153 define void @ShlConst(i32* nocapture %x) nounwind uwtable sanitize_memory {
154 entry:
155   %0 = load i32* %x, align 4
156   %1 = shl i32 %0, 10
157   store i32 %1, i32* %x, align 4
158   ret void
159 }
160
161 ; CHECK: @ShlConst
162 ; CHECK: = load
163 ; CHECK: = load
164 ; CHECK: shl
165 ; CHECK: shl
166 ; CHECK: store
167 ; CHECK: store
168 ; CHECK: ret void
169
170 ; Compute shadow for "10 << x": it should have 'sext i1'.
171 define void @ShlNonConst(i32* nocapture %x) nounwind uwtable sanitize_memory {
172 entry:
173   %0 = load i32* %x, align 4
174   %1 = shl i32 10, %0
175   store i32 %1, i32* %x, align 4
176   ret void
177 }
178
179 ; CHECK: @ShlNonConst
180 ; CHECK: = load
181 ; CHECK: = load
182 ; CHECK: = sext i1
183 ; CHECK: store
184 ; CHECK: store
185 ; CHECK: ret void
186
187 ; SExt
188 define void @SExt(i32* nocapture %a, i16* nocapture %b) nounwind uwtable sanitize_memory {
189 entry:
190   %0 = load i16* %b, align 2
191   %1 = sext i16 %0 to i32
192   store i32 %1, i32* %a, align 4
193   ret void
194 }
195
196 ; CHECK: @SExt
197 ; CHECK: = load
198 ; CHECK: = load
199 ; CHECK: = sext
200 ; CHECK: = sext
201 ; CHECK: store
202 ; CHECK: store
203 ; CHECK: ret void
204
205
206 ; memset
207 define void @MemSet(i8* nocapture %x) nounwind uwtable sanitize_memory {
208 entry:
209   call void @llvm.memset.p0i8.i64(i8* %x, i8 42, i64 10, i32 1, i1 false)
210   ret void
211 }
212
213 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind
214
215 ; CHECK: @MemSet
216 ; CHECK: call i8* @__msan_memset
217 ; CHECK: ret void
218
219
220 ; memcpy
221 define void @MemCpy(i8* nocapture %x, i8* nocapture %y) nounwind uwtable sanitize_memory {
222 entry:
223   call void @llvm.memcpy.p0i8.p0i8.i64(i8* %x, i8* %y, i64 10, i32 1, i1 false)
224   ret void
225 }
226
227 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
228
229 ; CHECK: @MemCpy
230 ; CHECK: call i8* @__msan_memcpy
231 ; CHECK: ret void
232
233
234 ; memmove is lowered to a call
235 define void @MemMove(i8* nocapture %x, i8* nocapture %y) nounwind uwtable sanitize_memory {
236 entry:
237   call void @llvm.memmove.p0i8.p0i8.i64(i8* %x, i8* %y, i64 10, i32 1, i1 false)
238   ret void
239 }
240
241 declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
242
243 ; CHECK: @MemMove
244 ; CHECK: call i8* @__msan_memmove
245 ; CHECK: ret void
246
247
248 ; Check that we propagate shadow for "select"
249
250 define i32 @Select(i32 %a, i32 %b, i32 %c) nounwind uwtable readnone sanitize_memory {
251 entry:
252   %tobool = icmp ne i32 %c, 0
253   %cond = select i1 %tobool, i32 %a, i32 %b
254   ret i32 %cond
255 }
256
257 ; CHECK: @Select
258 ; CHECK: select
259 ; CHECK-NEXT: select
260 ; CHECK: ret i32
261
262
263 ; Check that we propagate origin for "select" with vector condition.
264 ; Select condition is flattened to i1, which is then used to select one of the
265 ; argument origins.
266
267 define <8 x i16> @SelectVector(<8 x i16> %a, <8 x i16> %b, <8 x i1> %c) nounwind uwtable readnone sanitize_memory {
268 entry:
269   %cond = select <8 x i1> %c, <8 x i16> %a, <8 x i16> %b
270   ret <8 x i16> %cond
271 }
272
273 ; CHECK-ORIGINS: @SelectVector
274 ; CHECK-ORIGINS: bitcast <8 x i1> {{.*}} to i8
275 ; CHECK-ORIGINS: icmp ne i8
276 ; CHECK-ORIGINS: select i1
277 ; CHECK-ORIGINS: ret <8 x i16>
278
279
280 define i8* @IntToPtr(i64 %x) nounwind uwtable readnone sanitize_memory {
281 entry:
282   %0 = inttoptr i64 %x to i8*
283   ret i8* %0
284 }
285
286 ; CHECK: @IntToPtr
287 ; CHECK: load i64*{{.*}}__msan_param_tls
288 ; CHECK-NEXT: inttoptr
289 ; CHECK-NEXT: store i64{{.*}}__msan_retval_tls
290 ; CHECK: ret i8
291
292
293 define i8* @IntToPtr_ZExt(i16 %x) nounwind uwtable readnone sanitize_memory {
294 entry:
295   %0 = inttoptr i16 %x to i8*
296   ret i8* %0
297 }
298
299 ; CHECK: @IntToPtr_ZExt
300 ; CHECK: zext
301 ; CHECK-NEXT: inttoptr
302 ; CHECK: ret i8
303
304
305 ; Check that we insert exactly one check on udiv
306 ; (2nd arg shadow is checked, 1st arg shadow is propagated)
307
308 define i32 @Div(i32 %a, i32 %b) nounwind uwtable readnone sanitize_memory {
309 entry:
310   %div = udiv i32 %a, %b
311   ret i32 %div
312 }
313
314 ; CHECK: @Div
315 ; CHECK: icmp
316 ; CHECK: call void @__msan_warning
317 ; CHECK-NOT: icmp
318 ; CHECK: udiv
319 ; CHECK-NOT: icmp
320 ; CHECK: ret i32
321
322
323 ; Check that we propagate shadow for x<0, x>=0, etc (i.e. sign bit tests)
324
325 define zeroext i1 @ICmpSLT(i32 %x) nounwind uwtable readnone sanitize_memory {
326   %1 = icmp slt i32 %x, 0
327   ret i1 %1
328 }
329
330 ; CHECK: @ICmpSLT
331 ; CHECK: icmp slt
332 ; CHECK-NOT: call void @__msan_warning
333 ; CHECK: icmp slt
334 ; CHECK-NOT: call void @__msan_warning
335 ; CHECK: ret i1
336
337 define zeroext i1 @ICmpSGE(i32 %x) nounwind uwtable readnone sanitize_memory {
338   %1 = icmp sge i32 %x, 0
339   ret i1 %1
340 }
341
342 ; CHECK: @ICmpSGE
343 ; CHECK: icmp slt
344 ; CHECK-NOT: call void @__msan_warning
345 ; CHECK: icmp sge
346 ; CHECK-NOT: call void @__msan_warning
347 ; CHECK: ret i1
348
349 define zeroext i1 @ICmpSGT(i32 %x) nounwind uwtable readnone sanitize_memory {
350   %1 = icmp sgt i32 0, %x
351   ret i1 %1
352 }
353
354 ; CHECK: @ICmpSGT
355 ; CHECK: icmp slt
356 ; CHECK-NOT: call void @__msan_warning
357 ; CHECK: icmp sgt
358 ; CHECK-NOT: call void @__msan_warning
359 ; CHECK: ret i1
360
361 define zeroext i1 @ICmpSLE(i32 %x) nounwind uwtable readnone sanitize_memory {
362   %1 = icmp sle i32 0, %x
363   ret i1 %1
364 }
365
366 ; CHECK: @ICmpSLE
367 ; CHECK: icmp slt
368 ; CHECK-NOT: call void @__msan_warning
369 ; CHECK: icmp sle
370 ; CHECK-NOT: call void @__msan_warning
371 ; CHECK: ret i1
372
373
374 ; Check that we propagate shadow for x<0, x>=0, etc (i.e. sign bit tests)
375 ; of the vector arguments.
376
377 define <2 x i1> @ICmpSLT_vector(<2 x i32*> %x) nounwind uwtable readnone sanitize_memory {
378   %1 = icmp slt <2 x i32*> %x, zeroinitializer
379   ret <2 x i1> %1
380 }
381
382 ; CHECK: @ICmpSLT_vector
383 ; CHECK: icmp slt <2 x i64>
384 ; CHECK-NOT: call void @__msan_warning
385 ; CHECK: icmp slt <2 x i32*>
386 ; CHECK-NOT: call void @__msan_warning
387 ; CHECK: ret <2 x i1>
388
389
390 ; Check that we propagate shadow for unsigned relational comparisons with
391 ; constants
392
393 define zeroext i1 @ICmpUGTConst(i32 %x) nounwind uwtable readnone sanitize_memory {
394 entry:
395   %cmp = icmp ugt i32 %x, 7
396   ret i1 %cmp
397 }
398
399 ; CHECK: @ICmpUGTConst
400 ; CHECK: icmp ugt i32
401 ; CHECK-NOT: call void @__msan_warning
402 ; CHECK: icmp ugt i32
403 ; CHECK-NOT: call void @__msan_warning
404 ; CHECK: icmp ugt i32
405 ; CHECK-NOT: call void @__msan_warning
406 ; CHECK: ret i1
407
408
409 ; Check that loads of shadow have the same aligment as the original loads.
410 ; Check that loads of origin have the aligment of max(4, original alignment).
411
412 define i32 @ShadowLoadAlignmentLarge() nounwind uwtable sanitize_memory {
413   %y = alloca i32, align 64
414   %1 = load volatile i32* %y, align 64
415   ret i32 %1
416 }
417
418 ; CHECK: @ShadowLoadAlignmentLarge
419 ; CHECK: load i32* {{.*}} align 64
420 ; CHECK: load volatile i32* {{.*}} align 64
421 ; CHECK: ret i32
422
423 define i32 @ShadowLoadAlignmentSmall() nounwind uwtable sanitize_memory {
424   %y = alloca i32, align 2
425   %1 = load volatile i32* %y, align 2
426   ret i32 %1
427 }
428
429 ; CHECK: @ShadowLoadAlignmentSmall
430 ; CHECK: load i32* {{.*}} align 2
431 ; CHECK: load volatile i32* {{.*}} align 2
432 ; CHECK: ret i32
433
434 ; CHECK-ORIGINS: @ShadowLoadAlignmentSmall
435 ; CHECK-ORIGINS: load i32* {{.*}} align 2
436 ; CHECK-ORIGINS: load i32* {{.*}} align 4
437 ; CHECK-ORIGINS: load volatile i32* {{.*}} align 2
438 ; CHECK-ORIGINS: ret i32
439
440
441 ; Test vector manipulation instructions.
442 ; Check that the same bit manipulation is applied to the shadow values.
443 ; Check that there is a zero test of the shadow of %idx argument, where present.
444
445 define i32 @ExtractElement(<4 x i32> %vec, i32 %idx) sanitize_memory {
446   %x = extractelement <4 x i32> %vec, i32 %idx
447   ret i32 %x
448 }
449
450 ; CHECK: @ExtractElement
451 ; CHECK: extractelement
452 ; CHECK: call void @__msan_warning
453 ; CHECK: extractelement
454 ; CHECK: ret i32
455
456 define <4 x i32> @InsertElement(<4 x i32> %vec, i32 %idx, i32 %x) sanitize_memory {
457   %vec1 = insertelement <4 x i32> %vec, i32 %x, i32 %idx
458   ret <4 x i32> %vec1
459 }
460
461 ; CHECK: @InsertElement
462 ; CHECK: insertelement
463 ; CHECK: call void @__msan_warning
464 ; CHECK: insertelement
465 ; CHECK: ret <4 x i32>
466
467 define <4 x i32> @ShuffleVector(<4 x i32> %vec, <4 x i32> %vec1) sanitize_memory {
468   %vec2 = shufflevector <4 x i32> %vec, <4 x i32> %vec1,
469                         <4 x i32> <i32 0, i32 4, i32 1, i32 5>
470   ret <4 x i32> %vec2
471 }
472
473 ; CHECK: @ShuffleVector
474 ; CHECK: shufflevector
475 ; CHECK-NOT: call void @__msan_warning
476 ; CHECK: shufflevector
477 ; CHECK: ret <4 x i32>
478
479
480 ; Test bswap intrinsic instrumentation
481 define i32 @BSwap(i32 %x) nounwind uwtable readnone sanitize_memory {
482   %y = tail call i32 @llvm.bswap.i32(i32 %x)
483   ret i32 %y
484 }
485
486 declare i32 @llvm.bswap.i32(i32) nounwind readnone
487
488 ; CHECK: @BSwap
489 ; CHECK-NOT: call void @__msan_warning
490 ; CHECK: @llvm.bswap.i32
491 ; CHECK-NOT: call void @__msan_warning
492 ; CHECK: @llvm.bswap.i32
493 ; CHECK-NOT: call void @__msan_warning
494 ; CHECK: ret i32
495
496
497 ; Store intrinsic.
498
499 define void @StoreIntrinsic(i8* %p, <4 x float> %x) nounwind uwtable sanitize_memory {
500   call void @llvm.x86.sse.storeu.ps(i8* %p, <4 x float> %x)
501   ret void
502 }
503
504 declare void @llvm.x86.sse.storeu.ps(i8*, <4 x float>) nounwind
505
506 ; CHECK: @StoreIntrinsic
507 ; CHECK-NOT: br
508 ; CHECK-NOT: = or
509 ; CHECK: store <4 x i32> {{.*}} align 1
510 ; CHECK: call void @llvm.x86.sse.storeu.ps
511 ; CHECK: ret void
512
513
514 ; Load intrinsic.
515
516 define <16 x i8> @LoadIntrinsic(i8* %p) nounwind uwtable sanitize_memory {
517   %call = call <16 x i8> @llvm.x86.sse3.ldu.dq(i8* %p)
518   ret <16 x i8> %call
519 }
520
521 declare <16 x i8> @llvm.x86.sse3.ldu.dq(i8* %p) nounwind
522
523 ; CHECK: @LoadIntrinsic
524 ; CHECK: load <16 x i8>* {{.*}} align 1
525 ; CHECK-NOT: br
526 ; CHECK-NOT: = or
527 ; CHECK: call <16 x i8> @llvm.x86.sse3.ldu.dq
528 ; CHECK: store <16 x i8> {{.*}} @__msan_retval_tls
529 ; CHECK: ret <16 x i8>
530
531 ; CHECK-ORIGINS: @LoadIntrinsic
532 ; CHECK-ORIGINS: [[ORIGIN:%[01-9a-z]+]] = load i32* {{.*}}
533 ; CHECK-ORIGINS: call <16 x i8> @llvm.x86.sse3.ldu.dq
534 ; CHECK-ORIGINS: store i32 {{.*}}[[ORIGIN]], i32* @__msan_retval_origin_tls
535 ; CHECK-ORIGINS: ret <16 x i8>
536
537
538 ; Simple NoMem intrinsic
539 ; Check that shadow is OR'ed, and origin is Select'ed
540 ; And no shadow checks!
541
542 define <8 x i16> @Paddsw128(<8 x i16> %a, <8 x i16> %b) nounwind uwtable sanitize_memory {
543   %call = call <8 x i16> @llvm.x86.sse2.padds.w(<8 x i16> %a, <8 x i16> %b)
544   ret <8 x i16> %call
545 }
546
547 declare <8 x i16> @llvm.x86.sse2.padds.w(<8 x i16> %a, <8 x i16> %b) nounwind
548
549 ; CHECK: @Paddsw128
550 ; CHECK-NEXT: load <8 x i16>* {{.*}} @__msan_param_tls
551 ; CHECK-NEXT: load <8 x i16>* {{.*}} @__msan_param_tls
552 ; CHECK-NEXT: = or <8 x i16>
553 ; CHECK-NEXT: call <8 x i16> @llvm.x86.sse2.padds.w
554 ; CHECK-NEXT: store <8 x i16> {{.*}} @__msan_retval_tls
555 ; CHECK-NEXT: ret <8 x i16>
556
557 ; CHECK-ORIGINS: @Paddsw128
558 ; CHECK-ORIGINS: load i32* {{.*}} @__msan_param_origin_tls
559 ; CHECK-ORIGINS: load i32* {{.*}} @__msan_param_origin_tls
560 ; CHECK-ORIGINS: = bitcast <8 x i16> {{.*}} to i128
561 ; CHECK-ORIGINS-NEXT: = icmp ne i128 {{.*}}, 0
562 ; CHECK-ORIGINS-NEXT: = select i1 {{.*}}, i32 {{.*}}, i32
563 ; CHECK-ORIGINS: call <8 x i16> @llvm.x86.sse2.padds.w
564 ; CHECK-ORIGINS: store i32 {{.*}} @__msan_retval_origin_tls
565 ; CHECK-ORIGINS: ret <8 x i16>
566
567
568 ; Test handling of vectors of pointers.
569 ; Check that shadow of such vector is a vector of integers.
570
571 define <8 x i8*> @VectorOfPointers(<8 x i8*>* %p) nounwind uwtable sanitize_memory {
572   %x = load <8 x i8*>* %p
573   ret <8 x i8*> %x
574 }
575
576 ; CHECK: @VectorOfPointers
577 ; CHECK: load <8 x i64>*
578 ; CHECK: load <8 x i8*>*
579 ; CHECK: store <8 x i64> {{.*}} @__msan_retval_tls
580 ; CHECK: ret <8 x i8*>
581
582 ; Test handling of va_copy.
583
584 declare void @llvm.va_copy(i8*, i8*) nounwind
585
586 define void @VACopy(i8* %p1, i8* %p2) nounwind uwtable sanitize_memory {
587   call void @llvm.va_copy(i8* %p1, i8* %p2) nounwind
588   ret void
589 }
590
591 ; CHECK: @VACopy
592 ; CHECK: call void @llvm.memset.p0i8.i64({{.*}}, i8 0, i64 24, i32 8, i1 false)
593 ; CHECK: ret void
594
595
596 ; Test handling of volatile stores.
597 ; Check that MemorySanitizer does not add a check of the value being stored.
598
599 define void @VolatileStore(i32* nocapture %p, i32 %x) nounwind uwtable sanitize_memory {
600 entry:
601   store volatile i32 %x, i32* %p, align 4
602   ret void
603 }
604
605 ; CHECK: @VolatileStore
606 ; CHECK-NOT: @__msan_warning
607 ; CHECK: ret void
608
609
610 ; Test that checks are omitted but shadow propagation is kept if
611 ; sanitize_memory attribute is missing.
612
613 define i32 @NoSanitizeMemory(i32 %x) uwtable {
614 entry:
615   %tobool = icmp eq i32 %x, 0
616   br i1 %tobool, label %if.end, label %if.then
617
618 if.then:                                          ; preds = %entry
619   tail call void @bar()
620   br label %if.end
621
622 if.end:                                           ; preds = %entry, %if.then
623   ret i32 %x
624 }
625
626 declare void @bar()
627
628 ; CHECK: @NoSanitizeMemory
629 ; CHECK-NOT: @__msan_warning
630 ; CHECK: load i32* {{.*}} @__msan_param_tls
631 ; CHECK-NOT: @__msan_warning
632 ; CHECK: store {{.*}} @__msan_retval_tls
633 ; CHECK-NOT: @__msan_warning
634 ; CHECK: ret i32