1 ; RUN: opt -basic-aa -print-memoryssa -dot-cfg-mssa=out.dot -enable-new-pm=0 -analyze < %s 2>&1 > /dev/null
2 ;RUN: FileCheck %s -input-file=out.dot
3 ; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>' -dot-cfg-mssa=out.dot < %s 2>&1 > /dev/null
4 ;RUN: FileCheck %s -input-file=out.dot
6 ; Test -dot-cfg-mssa option for -print-memoryssa.
7 ; Test is based on following C code with some forwarding basic blocks
8 ; added to show that only those blocks with memory ssa comments
13 ;int f(int *p, int *q, int *r) {
25 define signext i32 @f(i32* %p, i32* %q, i32* %r) {
30 %p.addr = alloca i32*, align 8
31 %q.addr = alloca i32*, align 8
32 %r.addr = alloca i32*, align 8
33 %i = alloca i32, align 4
34 store i32* %p, i32** %p.addr, align 8
35 store i32* %q, i32** %q.addr, align 8
36 store i32* %r, i32** %r.addr, align 8
37 %0 = bitcast i32* %i to i8*
38 store i32 0, i32* %i, align 4
39 %1 = load i32*, i32** %r.addr, align 8
40 %2 = load i32, i32* %1, align 4
41 %tobool = icmp ne i32 %2, 0
42 br i1 %tobool, label %if.then, label %if.else
45 store i32 1, i32* %i, align 4
52 call void bitcast (void (...)* @g to void ()*)()
56 %3 = load i32*, i32** %q.addr, align 8
57 %4 = load i32, i32* %3, align 4
58 %add = add nsw i32 %4, 1
59 %5 = load i32*, i32** %p.addr, align 8
60 store i32 %add, i32* %5, align 4
61 %6 = load i32, i32* %i, align 4
62 %tobool1 = icmp ne i32 %6, 0
63 br i1 %tobool1, label %if.then2, label %if.end3
66 %7 = load i32, i32* %i, align 4
67 %inc = add nsw i32 %7, 1
71 store i32 %inc, i32* %i, align 4
78 %8 = load i32*, i32** %q.addr, align 8
79 %9 = load i32, i32* %8, align 4
80 %10 = bitcast i32* %i to i8*
86 ; CHECK: digraph "MSSA"
87 ; CHECK-NEXT: label="MSSA";
88 ; CHECK: {{Node0x.* [shape=record,label="{entry:.*}"]}}
89 ; CHECK: {{[shape=record,style=filled, fillcolor=lightpink,label="{bb1:.*1 = MemoryDef(liveOnEntry).*2 = MemoryDef(1).*3 = MemoryDef(2).*4 = MemoryDef(3).*MemoryUse(3).*MemoryUse(liveOnEntry).*}"]}}
90 ; CHECK {{[shape=record,style=filled, fillcolor=lightpink,label="{if.then:.*5 = MemoryDef(4).*}"]}}
91 ; CHECK {{[shape=record,label="{bb2:.*}"]}}
92 ; CHECK {{[shape=record,style=filled, fillcolor=lightpink,label="{if.else:.*6 = MemoryDef(4).*}"]}}
93 ; CHECK {{[shape=record,style=filled, fillcolor=lightpink,label="{if.end:.*10 = MemoryPhi({bb2,5},{if.else,6})/*MemoryUse(2).*MemoryUse(10).*MemoryUse(1).*7 = MemoryDef(10).*MemoryUse(10).*}"]}}
94 ; CHECK {{[shape=record,style=filled, fillcolor=lightpink,label="{if.then2:.*MemoryUse(10).*}"]}}
95 ; CHECK {{[shape=record,style=filled, fillcolor=lightpink,label="{bb3:.*8 = MemoryDef(7).*}"]}}
96 ; CHECK {{[shape=record,style=filled, fillcolor=lightpink,label="{if.end3:.*9 = MemoryPhi({if.end,7},{bb3,8}).*}"]}}
97 ; CHECK {{[shape=record,style=filled, fillcolor=lightpink,label="{bb4:.*MemoryUse(2).*MemoryUse(7).*}"]}}