1 ; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>,verify<memoryssa>' -disable-output < %s 2>&1 | FileCheck %s
3 ; Ensures that volatile stores/loads count as MemoryDefs
5 ; CHECK-LABEL: define i32 @foo
7 %1 = alloca i32, align 4
8 ; CHECK: 1 = MemoryDef(liveOnEntry)
9 ; CHECK-NEXT: store volatile i32 4
10 store volatile i32 4, ptr %1, align 4
11 ; CHECK: 2 = MemoryDef(1)
12 ; CHECK-NEXT: store volatile i32 8
13 store volatile i32 8, ptr %1, align 4
14 ; CHECK: 3 = MemoryDef(2)
15 ; CHECK-NEXT: %2 = load volatile i32
16 %2 = load volatile i32, ptr %1, align 4
17 ; CHECK: 4 = MemoryDef(3)
18 ; CHECK-NEXT: %3 = load volatile i32
19 %3 = load volatile i32, ptr %1, align 4
24 ; Ensuring we allow hoisting nonvolatile loads around volatile loads.
25 ; CHECK-LABEL: define void @volatile_only
26 define void @volatile_only(ptr %arg1, ptr %arg2) {
27 ; Trivially NoAlias/MustAlias
31 ; CHECK: 1 = MemoryDef(liveOnEntry)
32 ; CHECK-NEXT: load volatile i32, ptr %a
33 load volatile i32, ptr %a
34 ; CHECK: MemoryUse(liveOnEntry)
35 ; CHECK-NEXT: load i32, ptr %b
37 ; CHECK: MemoryUse(liveOnEntry)
38 ; CHECK-NEXT: load i32, ptr %a
42 ; CHECK: 2 = MemoryDef(1)
43 ; CHECK-NEXT: load volatile i32, ptr %arg1
44 load volatile i32, ptr %arg1
45 ; CHECK: MemoryUse(liveOnEntry)
46 ; CHECK-NEXT: load i32, ptr %arg2
52 ; Ensuring that volatile atomic operations work properly.
53 ; CHECK-LABEL: define void @volatile_atomics
54 define void @volatile_atomics(ptr %arg1, ptr %arg2) {
58 ; Trivially NoAlias/MustAlias
60 ; CHECK: 1 = MemoryDef(liveOnEntry)
61 ; CHECK-NEXT: load atomic volatile i32, ptr %a acquire, align 4
62 load atomic volatile i32, ptr %a acquire, align 4
64 ; CHECK-NEXT: load i32, ptr %b
67 ; CHECK: 2 = MemoryDef(1)
68 ; CHECK-NEXT: load atomic volatile i32, ptr %a monotonic, align 4
69 load atomic volatile i32, ptr %a monotonic, align 4
71 ; CHECK-NEXT: load i32, ptr %b
74 ; CHECK-NEXT: load atomic i32, ptr %b unordered, align 4
75 load atomic i32, ptr %b unordered, align 4
77 ; CHECK-NEXT: load atomic i32, ptr %a unordered, align 4
78 load atomic i32, ptr %a unordered, align 4
80 ; CHECK-NEXT: load i32, ptr %a
84 ; CHECK: 3 = MemoryDef(2)
85 ; CHECK-NEXT: load atomic volatile i32, ptr %arg1 monotonic, align 4
86 load atomic volatile i32, ptr %arg1 monotonic, align 4
88 ; CHECK-NEXT: load i32, ptr %arg2