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%struct.hoge = type { i32, %struct.widget } 5%struct.widget = type { i64 } 6 7define hidden void @quux(%struct.hoge *%f) align 2 { 8 %tmp = getelementptr inbounds %struct.hoge, %struct.hoge* %f, i64 0, i32 1, i32 0 9 %tmp24 = getelementptr inbounds %struct.hoge, %struct.hoge* %f, i64 0, i32 1 10 %tmp25 = bitcast %struct.widget* %tmp24 to i64** 11 br label %bb26 12 13bb26: ; preds = %bb77, %0 14; CHECK: 3 = MemoryPhi({%0,liveOnEntry},{bb77,2}) 15; CHECK-NEXT: br i1 undef, label %bb68, label %bb77 16 br i1 undef, label %bb68, label %bb77 17 18bb68: ; preds = %bb26 19; CHECK: MemoryUse(liveOnEntry) 20; CHECK-NEXT: %tmp69 = load i64, i64* null, align 8 21 %tmp69 = load i64, i64* null, align 8 22; CHECK: 1 = MemoryDef(3) 23; CHECK-NEXT: store i64 %tmp69, i64* %tmp, align 8 24 store i64 %tmp69, i64* %tmp, align 8 25 br label %bb77 26 27bb77: ; preds = %bb68, %bb26 28; CHECK: 2 = MemoryPhi({bb26,3},{bb68,1}) 29; CHECK: MemoryUse(2) 30; CHECK-NEXT: %tmp78 = load i64*, i64** %tmp25, align 8 31 %tmp78 = load i64*, i64** %tmp25, align 8 32 %tmp79 = getelementptr inbounds i64, i64* %tmp78, i64 undef 33 br label %bb26 34} 35 36; CHECK-LABEL: define void @quux_skip 37define void @quux_skip(%struct.hoge* noalias %f, i64* noalias %g) align 2 { 38 %tmp = getelementptr inbounds %struct.hoge, %struct.hoge* %f, i64 0, i32 1, i32 0 39 %tmp24 = getelementptr inbounds %struct.hoge, %struct.hoge* %f, i64 0, i32 1 40 %tmp25 = bitcast %struct.widget* %tmp24 to i64** 41 br label %bb26 42 43bb26: ; preds = %bb77, %0 44; CHECK: 3 = MemoryPhi({%0,liveOnEntry},{bb77,2}) 45; CHECK-NEXT: br i1 undef, label %bb68, label %bb77 46 br i1 undef, label %bb68, label %bb77 47 48bb68: ; preds = %bb26 49; CHECK: MemoryUse(3) 50; CHECK-NEXT: %tmp69 = load i64, i64* %g, align 8 51 %tmp69 = load i64, i64* %g, align 8 52; CHECK: 1 = MemoryDef(3) 53; CHECK-NEXT: store i64 %tmp69, i64* %g, align 8 54 store i64 %tmp69, i64* %g, align 8 55 br label %bb77 56 57bb77: ; preds = %bb68, %bb26 58; CHECK: 2 = MemoryPhi({bb26,3},{bb68,1}) 59; FIXME: This should be MemoryUse(liveOnEntry) 60; CHECK: MemoryUse(3) 61; CHECK-NEXT: %tmp78 = load i64*, i64** %tmp25, align 8 62 %tmp78 = load i64*, i64** %tmp25, align 8 63 br label %bb26 64} 65 66; CHECK-LABEL: define void @quux_dominated 67define void @quux_dominated(%struct.hoge* noalias %f, i64* noalias %g) align 2 { 68 %tmp = getelementptr inbounds %struct.hoge, %struct.hoge* %f, i64 0, i32 1, i32 0 69 %tmp24 = getelementptr inbounds %struct.hoge, %struct.hoge* %f, i64 0, i32 1 70 %tmp25 = bitcast %struct.widget* %tmp24 to i64** 71 br label %bb26 72 73bb26: ; preds = %bb77, %0 74; CHECK: 4 = MemoryPhi({%0,liveOnEntry},{bb77,2}) 75; CHECK: MemoryUse(4) 76; CHECK-NEXT: load i64*, i64** %tmp25, align 8 77 load i64*, i64** %tmp25, align 8 78 br i1 undef, label %bb68, label %bb77 79 80bb68: ; preds = %bb26 81; CHECK: MemoryUse(4) 82; CHECK-NEXT: %tmp69 = load i64, i64* %g, align 8 83 %tmp69 = load i64, i64* %g, align 8 84; CHECK: 1 = MemoryDef(4) 85; CHECK-NEXT: store i64 %tmp69, i64* %g, align 8 86 store i64 %tmp69, i64* %g, align 8 87 br label %bb77 88 89bb77: ; preds = %bb68, %bb26 90; CHECK: 3 = MemoryPhi({bb26,4},{bb68,1}) 91; CHECK: 2 = MemoryDef(3) 92; CHECK-NEXT: store i64* null, i64** %tmp25, align 8 93 store i64* null, i64** %tmp25, align 8 94 br label %bb26 95} 96 97; CHECK-LABEL: define void @quux_nodominate 98define void @quux_nodominate(%struct.hoge* noalias %f, i64* noalias %g) align 2 { 99 %tmp = getelementptr inbounds %struct.hoge, %struct.hoge* %f, i64 0, i32 1, i32 0 100 %tmp24 = getelementptr inbounds %struct.hoge, %struct.hoge* %f, i64 0, i32 1 101 %tmp25 = bitcast %struct.widget* %tmp24 to i64** 102 br label %bb26 103 104bb26: ; preds = %bb77, %0 105; CHECK: 3 = MemoryPhi({%0,liveOnEntry},{bb77,2}) 106; CHECK: MemoryUse(liveOnEntry) 107; CHECK-NEXT: load i64*, i64** %tmp25, align 8 108 load i64*, i64** %tmp25, align 8 109 br i1 undef, label %bb68, label %bb77 110 111bb68: ; preds = %bb26 112; CHECK: MemoryUse(3) 113; CHECK-NEXT: %tmp69 = load i64, i64* %g, align 8 114 %tmp69 = load i64, i64* %g, align 8 115; CHECK: 1 = MemoryDef(3) 116; CHECK-NEXT: store i64 %tmp69, i64* %g, align 8 117 store i64 %tmp69, i64* %g, align 8 118 br label %bb77 119 120bb77: ; preds = %bb68, %bb26 121; CHECK: 2 = MemoryPhi({bb26,3},{bb68,1}) 122; CHECK-NEXT: br label %bb26 123 br label %bb26 124} 125