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 5 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 9; are colourized. 10 11;void g(); 12 13;int f(int *p, int *q, int *r) { 14; int i = 0; 15; if (*r) 16; i = 1; 17; else 18; g(); 19; *p = *q + 1; 20; if (i) 21; ++i; 22; return *q; 23;} 24 25define signext i32 @f(i32* %p, i32* %q, i32* %r) { 26entry: 27 br label %bb1 28 29bb1: 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 43 44if.then: 45 store i32 1, i32* %i, align 4 46 br label %bb2 47 48bb2: 49 br label %if.end 50 51if.else: 52 call void bitcast (void (...)* @g to void ()*)() 53 br label %if.end 54 55if.end: 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 64 65if.then2: 66 %7 = load i32, i32* %i, align 4 67 %inc = add nsw i32 %7, 1 68 br label %bb3 69 70bb3: 71 store i32 %inc, i32* %i, align 4 72 br label %if.end3 73 74if.end3: 75 br label %bb4 76 77bb4: 78 %8 = load i32*, i32** %q.addr, align 8 79 %9 = load i32, i32* %8, align 4 80 %10 = bitcast i32* %i to i8* 81 ret i32 %9 82} 83 84declare void @g(...) 85 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).*}"]}} 98