forked from OSchip/llvm-project
[GVN] Set phi entries of unreachable predecessors to poison instead of undef
This matches NewGVN's behavior.
This commit is contained in:
parent
9b8f9d33db
commit
84b285d6eb
|
@ -1769,7 +1769,7 @@ bool GVNPass::processAssumeIntrinsic(AssumeInst *IntrinsicI) {
|
|||
// Insert a new store to null instruction before the load to indicate that
|
||||
// this code is not reachable. FIXME: We could insert unreachable
|
||||
// instruction directly because we can modify the CFG.
|
||||
auto *NewS = new StoreInst(UndefValue::get(Int8Ty),
|
||||
auto *NewS = new StoreInst(PoisonValue::get(Int8Ty),
|
||||
Constant::getNullValue(Int8Ty->getPointerTo()),
|
||||
IntrinsicI);
|
||||
if (MSSAU) {
|
||||
|
@ -2991,12 +2991,12 @@ void GVNPass::addDeadBlock(BasicBlock *BB) {
|
|||
}
|
||||
}
|
||||
|
||||
// Now undef the incoming values from the dead predecessors.
|
||||
// Now poison the incoming values from the dead predecessors.
|
||||
for (BasicBlock *P : predecessors(B)) {
|
||||
if (!DeadBlocks.count(P))
|
||||
continue;
|
||||
for (PHINode &Phi : B->phis()) {
|
||||
Phi.setIncomingValueForBlock(P, UndefValue::get(Phi.getType()));
|
||||
Phi.setIncomingValueForBlock(P, PoisonValue::get(Phi.getType()));
|
||||
if (MD)
|
||||
MD->invalidateCachedPointerInfo(&Phi);
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ entry:
|
|||
bb2:
|
||||
; CHECK-NOT: %cmp3 =
|
||||
%cmp3 = icmp eq i32 %p, 43
|
||||
; CHECK: store i8 undef, i8* null
|
||||
; CHECK: store i8 poison, i8* null
|
||||
call void @llvm.assume(i1 %cmp3)
|
||||
ret i32 15
|
||||
bb3:
|
||||
|
|
|
@ -68,7 +68,7 @@ return: ; preds = %bb27
|
|||
; CHECK: bb26:
|
||||
; CHECK: br label %bb27
|
||||
; CHECK: bb27:
|
||||
; CHECK: %tmp.0 = phi i32 [ 11, %bb26 ], [ undef, %bb24 ], [ undef, %bb14 ], [ %g, %bb ]
|
||||
; CHECK: %tmp.0 = phi i32 [ 11, %bb26 ], [ poison, %bb24 ], [ poison, %bb14 ], [ %g, %bb ]
|
||||
; CHECK: ret i32 %tmp.0
|
||||
; CHECK: }
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ define i32 @test1() nounwind {
|
|||
; CHECK: bb7:
|
||||
; CHECK-NEXT: br label [[BB8]]
|
||||
; CHECK: bb8:
|
||||
; CHECK-NEXT: [[DOT0:%.*]] = phi i32 [ [[TMP0]], [[BB7]] ], [ undef, [[BB6]] ], [ undef, [[BB4]] ], [ 4, [[BB2]] ], [ 5, [[BB]] ]
|
||||
; CHECK-NEXT: [[DOT0:%.*]] = phi i32 [ [[TMP0]], [[BB7]] ], [ poison, [[BB6]] ], [ poison, [[BB4]] ], [ 4, [[BB2]] ], [ 5, [[BB]] ]
|
||||
; CHECK-NEXT: ret i32 [[DOT0]]
|
||||
;
|
||||
entry:
|
||||
|
|
|
@ -149,7 +149,7 @@ merge:
|
|||
|
||||
define i32 @conflicting_constants(i32* %p) {
|
||||
; CHECK-LABEL: @conflicting_constants(
|
||||
; CHECK-NEXT: store i8 undef, i8* null
|
||||
; CHECK-NEXT: store i8 poison, i8* null
|
||||
; CHECK-NEXT: br i1 undef, label [[TAKEN:%.*]], label [[MERGE:%.*]]
|
||||
; CHECK: taken:
|
||||
; CHECK-NEXT: br label [[MERGE]]
|
||||
|
|
|
@ -97,7 +97,7 @@ for.body.i22:
|
|||
define void @test_assume_false_to_store_undef_1(i32* %ptr) {
|
||||
; CHECK-LABEL: @test_assume_false_to_store_undef_1(
|
||||
; CHECK-NEXT: store i32 10, i32* [[PTR:%.*]], align 4
|
||||
; CHECK-NEXT: store i8 undef, i8* null, align 1
|
||||
; CHECK-NEXT: store i8 poison, i8* null, align 1
|
||||
; CHECK-NEXT: call void @f()
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
|
@ -113,7 +113,7 @@ define i32 @test_assume_false_to_store_undef_2(i32* %ptr, i32* %ptr.2) {
|
|||
; CHECK-LABEL: @test_assume_false_to_store_undef_2(
|
||||
; CHECK-NEXT: store i32 10, i32* [[PTR:%.*]], align 4
|
||||
; CHECK-NEXT: [[LV:%.*]] = load i32, i32* [[PTR_2:%.*]], align 4
|
||||
; CHECK-NEXT: store i8 undef, i8* null, align 1
|
||||
; CHECK-NEXT: store i8 poison, i8* null, align 1
|
||||
; CHECK-NEXT: call void @f()
|
||||
; CHECK-NEXT: ret i32 [[LV]]
|
||||
;
|
||||
|
@ -130,7 +130,7 @@ define i32 @test_assume_false_to_store_undef_3(i32* %ptr, i32* %ptr.2) {
|
|||
; CHECK-LABEL: @test_assume_false_to_store_undef_3(
|
||||
; CHECK-NEXT: store i32 10, i32* [[PTR:%.*]], align 4
|
||||
; CHECK-NEXT: [[LV:%.*]] = load i32, i32* [[PTR_2:%.*]], align 4
|
||||
; CHECK-NEXT: store i8 undef, i8* null, align 1
|
||||
; CHECK-NEXT: store i8 poison, i8* null, align 1
|
||||
; CHECK-NEXT: ret i32 [[LV]]
|
||||
;
|
||||
store i32 10, i32* %ptr
|
||||
|
|
Loading…
Reference in New Issue