1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
  
     | 
    
      ; RUN: opt -disable-output -aa-pipeline=basic-aa -passes='loop-mssa(licm),print<memoryssa>' < %s 2>&1 | FileCheck %s
target triple = "x86_64-unknown-linux-gnu"
; CHECK-LABEL: @main(i1 %arg)
; CHECK: 5 = MemoryPhi(
; CHECK-NOT: 7 = MemoryPhi(
@v_67 = external dso_local global i32, align 1
@v_76 = external dso_local global i16, align 1
@v_86 = external dso_local global ptr, align 1
define dso_local void @main(i1 %arg) {
entry:
  %v_59 = alloca i16, align 2
  br label %for.cond
for.cond:                                         ; preds = %for.body, %entry
  br i1 %arg, label %for.body, label %for.end
for.body:                                         ; preds = %for.cond
  store i16 undef, ptr %v_59, align 2
  br label %for.cond
for.end:                                          ; preds = %for.cond
  br i1 %arg, label %if.else568, label %cond.end82
cond.false69:                                     ; No predecessors!
  br label %cond.end82
cond.end82:                                       ; preds = %cond.false69, %cond.true55
  br i1 %arg, label %if.else568, label %land.lhs.true87
land.lhs.true87:                                  ; preds = %cond.end82
  br i1 %arg, label %if.then88, label %if.else568
if.then88:                                        ; preds = %land.lhs.true87
  store ptr @v_76, ptr @v_86, align 1
  br label %if.end569
if.else568:                                       ; preds = %land.lhs.true87, %cond.end82, %for.end
  store volatile i32 undef, ptr @v_67, align 1
  br label %if.end569
if.end569:                                        ; preds = %if.else568, %if.then88
  ret void
}
; CHECK-LABEL: @f(i1 %arg)
; CHECK: 7 = MemoryPhi(
; CHECK: 6 = MemoryPhi(
; CHECK: 10 = MemoryPhi(
; CHECK: 9 = MemoryPhi(
; CHECK: 8 = MemoryPhi(
define void @f(i1 %arg) {
entry:
  %e = alloca i16, align 1
  br label %lbl1
lbl1:                                             ; preds = %if.else, %for.end5, %entry
  store i16 undef, ptr %e, align 1
  %0 = load i16, ptr %e, align 1
  %call = call i16 @g(i16 %0)
  br i1 %arg, label %for.end, label %if.else
for.end:                                          ; preds = %if.then
  br i1 true, label %for.cond2, label %lbl2
lbl2:                                             ; preds = %for.body4, %if.end
  br label %for.cond2
for.cond2:                                        ; preds = %lbl3
  br i1 %arg, label %for.body4, label %for.end5
for.body4:                                        ; preds = %for.cond2
  br label %lbl2
for.end5:                                         ; preds = %for.cond2
  switch i32 undef, label %unreachable [
    i32 0, label %if.end12
    i32 2, label %lbl1
  ]
if.else:                                          ; preds = %lbl1
  switch i32 undef, label %unreachable [
    i32 0, label %if.end12
    i32 2, label %lbl1
  ]
if.end12:                                         ; preds = %cleanup.cont11s, %cleanup.cont
  call void @llvm.lifetime.end.p0(i64 1, ptr undef)
  ret void
unreachable:                                      ; preds = %if.else, %for.end5
  unreachable
}
declare i16 @g(i16)
; Function Attrs: argmemonly nounwind willreturn
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
 
     |