forked from OSchip/llvm-project
Revert "[SimplifyCFG] `markAliveBlocks()`: recognize that normal dest of `invoke`d `noreturn` function is `unreachable`"
The normal destination may have other uses.
This reverts commit 598833c987
.
This commit is contained in:
parent
981f0a14f1
commit
db1176ce66
|
@ -2349,32 +2349,19 @@ static bool markAliveBlocks(Function &F,
|
|||
isa<UndefValue>(Callee)) {
|
||||
changeToUnreachable(II, false, DTU);
|
||||
Changed = true;
|
||||
} else {
|
||||
if (II->doesNotReturn()) {
|
||||
// If we found an invoke of a no-return function,
|
||||
// insert an unreachable instruction after it (on the normal dest).
|
||||
// Make sure there isn't *already* one there though.
|
||||
Instruction *FirstNormalInst = &II->getNormalDest()->front();
|
||||
if (!isa<UnreachableInst>(FirstNormalInst)) {
|
||||
// Don't insert a call to llvm.trap right before the unreachable.
|
||||
changeToUnreachable(FirstNormalInst, false, DTU);
|
||||
Changed = true;
|
||||
}
|
||||
}
|
||||
if (II->doesNotThrow() && canSimplifyInvokeNoUnwind(&F)) {
|
||||
if (II->use_empty() && II->onlyReadsMemory()) {
|
||||
// jump to the normal destination branch.
|
||||
BasicBlock *NormalDestBB = II->getNormalDest();
|
||||
BasicBlock *UnwindDestBB = II->getUnwindDest();
|
||||
BranchInst::Create(NormalDestBB, II);
|
||||
UnwindDestBB->removePredecessor(II->getParent());
|
||||
II->eraseFromParent();
|
||||
if (DTU)
|
||||
DTU->applyUpdates({{DominatorTree::Delete, BB, UnwindDestBB}});
|
||||
} else
|
||||
changeToCall(II, DTU);
|
||||
Changed = true;
|
||||
}
|
||||
} else if (II->doesNotThrow() && canSimplifyInvokeNoUnwind(&F)) {
|
||||
if (II->use_empty() && II->onlyReadsMemory()) {
|
||||
// jump to the normal destination branch.
|
||||
BasicBlock *NormalDestBB = II->getNormalDest();
|
||||
BasicBlock *UnwindDestBB = II->getUnwindDest();
|
||||
BranchInst::Create(NormalDestBB, II);
|
||||
UnwindDestBB->removePredecessor(II->getParent());
|
||||
II->eraseFromParent();
|
||||
if (DTU)
|
||||
DTU->applyUpdates({{DominatorTree::Delete, BB, UnwindDestBB}});
|
||||
} else
|
||||
changeToCall(II, DTU);
|
||||
Changed = true;
|
||||
}
|
||||
} else if (auto *CatchSwitch = dyn_cast<CatchSwitchInst>(Terminator)) {
|
||||
// Remove catchpads which cannot be reached.
|
||||
|
|
|
@ -4,7 +4,7 @@ target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
|
|||
target triple = "x86_64-pc-windows-msvc"
|
||||
|
||||
declare i32 @__CxxFrameHandler3(...)
|
||||
declare void @throw() uwtable
|
||||
declare void @throw() noreturn uwtable
|
||||
declare i8* @getval()
|
||||
declare void @llvm.trap()
|
||||
|
||||
|
|
|
@ -198,7 +198,8 @@ define void @invoke_of_noreturn() personality i8* bitcast (i32 (...)* @__gxx_per
|
|||
; CHECK-NEXT: invoke void @simple_throw()
|
||||
; CHECK-NEXT: to label [[INVOKE_CONT:%.*]] unwind label [[LPAD:%.*]]
|
||||
; CHECK: invoke.cont:
|
||||
; CHECK-NEXT: unreachable
|
||||
; CHECK-NEXT: call void @sideeffect(i32 0)
|
||||
; CHECK-NEXT: ret void
|
||||
; CHECK: lpad:
|
||||
; CHECK-NEXT: [[EH:%.*]] = landingpad { i8*, i32 }
|
||||
; CHECK-NEXT: cleanup
|
||||
|
|
Loading…
Reference in New Issue