• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -basic-aa -print-memoryssa -verify-memoryssa -enable-new-pm=0 -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
3;
4; Ensuring that external functions without attributes are MemoryDefs
5
6@g = external global i32
7declare void @modifyG()
8
9define i32 @foo() {
10; CHECK: MemoryUse(liveOnEntry)
11; CHECK-NEXT: %1 = load i32
12  %1 = load i32, i32* @g
13
14; CHECK: 1 = MemoryDef(liveOnEntry)
15; CHECK-NEXT: store i32 4
16  store i32 4, i32* @g, align 4
17
18; CHECK: 2 = MemoryDef(1)
19; CHECK-NEXT: call void @modifyG()
20  call void @modifyG()
21
22; CHECK: MemoryUse(2)
23; CHECK-NEXT: %2 = load i32
24  %2 = load i32, i32* @g
25  %3 = add i32 %2, %1
26  ret i32 %3
27}
28
29declare void @readEverything() readonly
30declare void @clobberEverything()
31
32; CHECK-LABEL: define void @bar
33define void @bar() {
34; CHECK: 1 = MemoryDef(liveOnEntry)
35; CHECK-NEXT: call void @clobberEverything()
36  call void @clobberEverything()
37  br i1 undef, label %if.end, label %if.then
38
39if.then:
40; CHECK: MemoryUse(1)
41; CHECK-NEXT: call void @readEverything()
42  call void @readEverything()
43; CHECK: 2 = MemoryDef(1)
44; CHECK-NEXT: call void @clobberEverything()
45  call void @clobberEverything()
46  br label %if.end
47
48if.end:
49; CHECK: 3 = MemoryPhi({%0,1},{if.then,2})
50; CHECK: MemoryUse(3)
51; CHECK-NEXT: call void @readEverything()
52  call void @readEverything()
53  ret void
54}
55