• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3;
4; Testing many dominators, specifically from a switch statement in C.
5
6declare i1 @getBool() readnone
7
8define i32 @foo(i32* %p) {
9entry:
10  br label %loopbegin
11
12loopbegin:
13; CHECK: 8 = MemoryPhi({entry,liveOnEntry},{sw.epilog,6})
14; CHECK-NEXT: %n =
15  %n = phi i32 [ 0, %entry ], [ %1, %sw.epilog ]
16  %m = alloca i32, align 4
17  switch i32 %n, label %sw.default [
18    i32 0, label %sw.bb
19    i32 1, label %sw.bb1
20    i32 2, label %sw.bb2
21    i32 3, label %sw.bb3
22  ]
23
24sw.bb:
25; CHECK: 1 = MemoryDef(8)
26; CHECK-NEXT: store i32 1
27  store i32 1, i32* %m, align 4
28  br label %sw.epilog
29
30sw.bb1:
31; CHECK: 2 = MemoryDef(8)
32; CHECK-NEXT: store i32 2
33  store i32 2, i32* %m, align 4
34  br label %sw.epilog
35
36sw.bb2:
37; CHECK: 3 = MemoryDef(8)
38; CHECK-NEXT: store i32 3
39  store i32 3, i32* %m, align 4
40  br label %sw.epilog
41
42sw.bb3:
43; CHECK: 4 = MemoryDef(8)
44; CHECK-NEXT: store i32 4
45  store i32 4, i32* %m, align 4
46  br label %sw.epilog
47
48sw.default:
49; CHECK: 5 = MemoryDef(8)
50; CHECK-NEXT: store i32 5
51  store i32 5, i32* %m, align 4
52  br label %sw.epilog
53
54sw.epilog:
55; CHECK: 7 = MemoryPhi({sw.default,5},{sw.bb,1},{sw.bb1,2},{sw.bb2,3},{sw.bb3,4})
56; CHECK-NEXT: MemoryUse(7)
57; CHECK-NEXT: %0 =
58  %0 = load i32, i32* %m, align 4
59; CHECK: 6 = MemoryDef(7)
60; CHECK-NEXT: %1 =
61  %1 = load volatile i32, i32* %p, align 4
62  %2 = icmp eq i32 %0, %1
63  br i1 %2, label %exit, label %loopbegin
64
65exit:
66  ret i32 %1
67}
68