BasicBlock *BB = I->getParent();
Instruction *SplitPos = I->getNextNode();
// TODO: mark stuff before unreachable instructions as dead.
- if (isa_and_nonnull<UnreachableInst>(SplitPos))
- continue;
if (auto *II = dyn_cast<InvokeInst>(I)) {
// If we keep the invoke the split position is at the beginning of the
// also manifest.
assert(!NormalDestBB->isLandingPad() &&
"Expected the normal destination not to be a landingpad!");
- BasicBlock *SplitBB =
- SplitBlockPredecessors(NormalDestBB, {BB}, ".dead");
- // The split block is live even if it contains only an unreachable
- // instruction at the end.
- assumeLive(A, *SplitBB);
- SplitPos = SplitBB->getTerminator();
+ if (NormalDestBB->getUniquePredecessor() == BB) {
+ assumeLive(A, *NormalDestBB);
+ } else {
+ BasicBlock *SplitBB =
+ SplitBlockPredecessors(NormalDestBB, {BB}, ".dead");
+ // The split block is live even if it contains only an unreachable
+ // instruction at the end.
+ assumeLive(A, *SplitBB);
+ SplitPos = SplitBB->getTerminator();
+ HasChanged = ChangeStatus::CHANGED;
+ }
}
}
+ if (isa_and_nonnull<UnreachableInst>(SplitPos))
+ continue;
+
BB = SplitPos->getParent();
SplitBlock(BB, SplitPos);
changeToUnreachable(BB->getTerminator(), /* UseLLVMTrap */ false);
%call = invoke i32 @foo_noreturn() to label %continue
unwind label %cleanup
; CHECK: %call = invoke i32 @foo_noreturn()
- ; CHECK-NEXT: to label %continue.dead unwind label %cleanup
+ ; CHECK-NEXT: to label %continue unwind label %cleanup
cond.false: ; preds = %entry
call void @normal_call()
ret i32 %cond
continue:
- ; CHECK: continue.dead:
+ ; CHECK: continue:
; CHECK-NEXT: unreachable
br label %cond.end
%retval = alloca i32, align 4
%__exception_code = alloca i32, align 4
; CHECK: invoke void @"?overflow@@YAXXZ"()
-; CHECK: to label %invoke.cont.dead unwind label %catch.dispatch
+; CHECK: to label %invoke.cont unwind label %catch.dispatch
invoke void @"?overflow@@YAXXZ"()
to label %invoke.cont unwind label %catch.dispatch
invoke.cont: ; preds = %entry
-; CHECK: invoke.cont.dead:
+; CHECK: invoke.cont:
; CHECK-NEXT: unreachable
br label %invoke.cont1
%retval = alloca i32, align 4
%__exception_code = alloca i32, align 4
; CHECK: invoke void @"?overflow@@YAXXZ_may_throw"()
-; CHECK: to label %invoke.cont.dead unwind label %catch.dispatch
+; CHECK: to label %invoke.cont unwind label %catch.dispatch
invoke void @"?overflow@@YAXXZ_may_throw"()
to label %invoke.cont unwind label %catch.dispatch
invoke.cont: ; preds = %entry
-; CHECK: invoke.cont.dead:
+; CHECK: invoke.cont:
; CHECK-NEXT: unreachable
br label %invoke.cont1
%retval = alloca i32, align 4
%__exception_code = alloca i32, align 4
; CHECK: invoke void @"?overflow@@YAXXZ_may_throw"()
-; CHECK: to label %invoke.cont.dead unwind label %catch.dispatch
+; CHECK: to label %invoke.cont unwind label %catch.dispatch
invoke void @"?overflow@@YAXXZ_may_throw"()
to label %invoke.cont unwind label %catch.dispatch
invoke.cont: ; preds = %entry
-; CHECK: invoke.cont.dead:
+; CHECK: invoke.cont:
; CHECK-NEXT: unreachable
br label %invoke.cont1