1 ; RUN: opt -basicaa -print-memoryssa -verify-memoryssa -analyze < %s 2>&1 | FileCheck %s
2 ; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>,verify<memoryssa>' -disable-output < %s 2>&1 | FileCheck %s
4 ; Ensures that volatile stores/loads count as MemoryDefs
6 ; CHECK-LABEL: define i32 @foo
8 %1 = alloca i32, align 4
9 ; CHECK: 1 = MemoryDef(liveOnEntry)
10 ; CHECK-NEXT: store volatile i32 4
11 store volatile i32 4, i32* %1, align 4
12 ; CHECK: 2 = MemoryDef(1)
13 ; CHECK-NEXT: store volatile i32 8
14 store volatile i32 8, i32* %1, align 4
15 ; CHECK: 3 = MemoryDef(2)
16 ; CHECK-NEXT: %2 = load volatile i32
17 %2 = load volatile i32, i32* %1, align 4
18 ; CHECK: 4 = MemoryDef(3)
19 ; CHECK-NEXT: %3 = load volatile i32
20 %3 = load volatile i32, i32* %1, align 4
25 ; Ensuring we allow hoisting nonvolatile loads around volatile loads.
26 ; CHECK-LABEL define void @volatile_only
27 define void @volatile_only(i32* %arg1, i32* %arg2) {
28 ; Trivially NoAlias/MustAlias
32 ; CHECK: 1 = MemoryDef(liveOnEntry)
33 ; CHECK-NEXT: load volatile i32, i32* %a
34 load volatile i32, i32* %a
35 ; CHECK: MemoryUse(liveOnEntry)
36 ; CHECK-NEXT: load i32, i32* %b
38 ; CHECK: MemoryUse(liveOnEntry)
39 ; CHECK-NEXT: load i32, i32* %a
43 ; CHECK: 2 = MemoryDef(1)
44 ; CHECK-NEXT: load volatile i32, i32* %arg1
45 load volatile i32, i32* %arg1
46 ; CHECK: MemoryUse(liveOnEntry)
47 ; CHECK-NEXT: load i32, i32* %arg2
53 ; Ensuring that volatile atomic operations work properly.
54 ; CHECK-LABEL define void @volatile_atomics
55 define void @volatile_atomics(i32* %arg1, i32* %arg2) {
59 ; Trivially NoAlias/MustAlias
61 ; CHECK: 1 = MemoryDef(liveOnEntry)
62 ; CHECK-NEXT: load atomic volatile i32, i32* %a acquire, align 4
63 load atomic volatile i32, i32* %a acquire, align 4
65 ; CHECK-NEXT: load i32, i32* %b
68 ; CHECK: 2 = MemoryDef(1)
69 ; CHECK-NEXT: load atomic volatile i32, i32* %a monotonic, align 4
70 load atomic volatile i32, i32* %a monotonic, align 4
72 ; CHECK-NEXT: load i32, i32* %b
75 ; CHECK-NEXT: load atomic i32, i32* %b unordered, align 4
76 load atomic i32, i32* %b unordered, align 4
78 ; CHECK-NEXT: load atomic i32, i32* %a unordered, align 4
79 load atomic i32, i32* %a unordered, align 4
81 ; CHECK-NEXT: load i32, i32* %a
85 ; CHECK: 3 = MemoryDef(2)
86 ; CHECK-NEXT: load atomic volatile i32, i32* %arg1 monotonic, align 4
87 load atomic volatile i32, i32* %arg1 monotonic, align 4
89 ; CHECK-NEXT: load i32, i32* %arg2