1 ; RUN: opt -aa-pipeline=basic-aa -passes='print<memoryssa>' -dot-cfg-mssa=out.dot < %s 2>&1 > /dev/null
2 ; RUN: FileCheck %s -input-file=out.dot
4 ; Test -dot-cfg-mssa option for -print-memoryssa.
5 ; Test is based on following C code with some forwarding basic blocks
6 ; added to show that only those blocks with memory ssa comments
11 ;int f(int *p, int *q, int *r) {
23 define signext i32 @f(ptr %p, ptr %q, ptr %r) {
28 %p.addr = alloca ptr, align 8
29 %q.addr = alloca ptr, align 8
30 %r.addr = alloca ptr, align 8
31 %i = alloca i32, align 4
32 store ptr %p, ptr %p.addr, align 8
33 store ptr %q, ptr %q.addr, align 8
34 store ptr %r, ptr %r.addr, align 8
35 store i32 0, ptr %i, align 4
36 %0 = load ptr, ptr %r.addr, align 8
37 %1 = load i32, ptr %0, align 4
38 %tobool = icmp ne i32 %1, 0
39 br i1 %tobool, label %if.then, label %if.else
42 store i32 1, ptr %i, align 4
53 %2 = load ptr, ptr %q.addr, align 8
54 %3 = load i32, ptr %2, align 4
55 %add = add nsw i32 %3, 1
56 %4 = load ptr, ptr %p.addr, align 8
57 store i32 %add, ptr %4, align 4
58 %5 = load i32, ptr %i, align 4
59 %tobool1 = icmp ne i32 %5, 0
60 br i1 %tobool1, label %if.then2, label %if.end3
63 %6 = load i32, ptr %i, align 4
64 %inc = add nsw i32 %6, 1
68 store i32 %inc, ptr %i, align 4
75 %7 = load ptr, ptr %q.addr, align 8
76 %8 = load i32, ptr %7, align 4
82 ; CHECK: digraph "MSSA"
83 ; CHECK-NEXT: label="MSSA";
84 ; CHECK: {{Node0x.* [shape=record,label="{entry:.*}"]}}
85 ; 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).*}"]}}
86 ; CHECK: {{[shape=record,style=filled, fillcolor=lightpink,label="{if.then:.*5 = MemoryDef(4).*}"]}}
87 ; CHECK: {{[shape=record,label="{bb2:.*}"]}}
88 ; CHECK: {{[shape=record,style=filled, fillcolor=lightpink,label="{if.else:.*6 = MemoryDef(4).*}"]}}
89 ; 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).*}"]}}
90 ; CHECK: {{[shape=record,style=filled, fillcolor=lightpink,label="{if.then2:.*MemoryUse(10).*}"]}}
91 ; CHECK: {{[shape=record,style=filled, fillcolor=lightpink,label="{bb3:.*8 = MemoryDef(7).*}"]}}
92 ; CHECK: {{[shape=record,style=filled, fillcolor=lightpink,label="{if.end3:.*9 = MemoryPhi({if.end,7},{bb3,8}).*}"]}}
93 ; CHECK: {{[shape=record,style=filled, fillcolor=lightpink,label="{bb4:.*MemoryUse(2).*MemoryUse(7).*}"]}}