// See if we had a local def, and if not, go hunting.
MemoryAccess *DefBefore = getPreviousDef(MD);
- bool DefBeforeSameBlock = DefBefore->getBlock() == MD->getBlock();
+ bool DefBeforeSameBlock = false;
+ if (DefBefore->getBlock() == MD->getBlock() &&
+ !(isa<MemoryPhi>(DefBefore) &&
+ std::find(InsertedPHIs.begin(), InsertedPHIs.end(), DefBefore) !=
+ InsertedPHIs.end()))
+ DefBeforeSameBlock = true;
// There is a def before us, which means we can replace any store/phi uses
// of that thing with us, since we are in the way of whatever was there
// If NewMPhi is a trivial phi, remove it. Its use in the header MPhi will be
// replaced with the unique value.
- tryRemoveTrivialPhi(MPhi);
+ tryRemoveTrivialPhi(NewMPhi);
}
void MemorySSAUpdater::updateForClonedLoop(const LoopBlocksRPO &LoopBlocks,
ret void
}
+
+; CHECK-LABEL: @f()
+; CHECK: 8 = MemoryPhi(
+; CHECK: 7 = MemoryPhi(
+; CHECK: 11 = MemoryPhi(
+; CHECK: 10 = MemoryPhi(
+; CHECK: 9 = MemoryPhi(
+define void @f() {
+entry:
+ %e = alloca i16, align 1
+ br label %lbl1
+
+lbl1: ; preds = %if.else, %for.end5, %entry
+ store i16 undef, i16* %e, align 1
+ %0 = load i16, i16* %e, align 1
+ %call = call i16 @g(i16 %0)
+ br i1 undef, 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 undef, 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.p0i8(i64 1, i8* undef)
+ ret void
+
+unreachable: ; preds = %if.else, %for.end5
+ unreachable
+}
+
+declare i16 @g(i16)
+
+; Function Attrs: argmemonly nounwind willreturn
+declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)