aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/WinEHPrepare.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-07-29 20:15:26 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-07-29 20:15:26 +0000
commit344a3780b2e33f6ca763666c380202b18aab72a3 (patch)
treef0b203ee6eb71d7fdd792373e3c81eb18d6934dd /llvm/lib/CodeGen/WinEHPrepare.cpp
parentb60736ec1405bb0a8dd40989f67ef4c93da068ab (diff)
Diffstat (limited to 'llvm/lib/CodeGen/WinEHPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/WinEHPrepare.cpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp
index 96d256ba57a3..4564aa1c1278 100644
--- a/llvm/lib/CodeGen/WinEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WinEHPrepare.cpp
@@ -714,16 +714,14 @@ void WinEHPrepare::demotePHIsOnFunclets(Function &F,
bool DemoteCatchSwitchPHIOnly) {
// Strip PHI nodes off of EH pads.
SmallVector<PHINode *, 16> PHINodes;
- for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) {
- BasicBlock *BB = &*FI++;
- if (!BB->isEHPad())
+ for (BasicBlock &BB : make_early_inc_range(F)) {
+ if (!BB.isEHPad())
continue;
- if (DemoteCatchSwitchPHIOnly && !isa<CatchSwitchInst>(BB->getFirstNonPHI()))
+ if (DemoteCatchSwitchPHIOnly && !isa<CatchSwitchInst>(BB.getFirstNonPHI()))
continue;
- for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) {
- Instruction *I = &*BI++;
- auto *PN = dyn_cast<PHINode>(I);
+ for (Instruction &I : make_early_inc_range(BB)) {
+ auto *PN = dyn_cast<PHINode>(&I);
// Stop at the first non-PHI.
if (!PN)
break;
@@ -986,9 +984,9 @@ void WinEHPrepare::removeImplausibleInstructions(Function &F) {
BasicBlock::iterator CallI =
std::prev(BB->getTerminator()->getIterator());
auto *CI = cast<CallInst>(&*CallI);
- changeToUnreachable(CI, /*UseLLVMTrap=*/false);
+ changeToUnreachable(CI);
} else {
- changeToUnreachable(&I, /*UseLLVMTrap=*/false);
+ changeToUnreachable(&I);
}
// There are no more instructions in the block (except for unreachable),
@@ -1009,7 +1007,7 @@ void WinEHPrepare::removeImplausibleInstructions(Function &F) {
IsUnreachableCleanupret = CRI->getCleanupPad() != CleanupPad;
if (IsUnreachableRet || IsUnreachableCatchret ||
IsUnreachableCleanupret) {
- changeToUnreachable(TI, /*UseLLVMTrap=*/false);
+ changeToUnreachable(TI);
} else if (isa<InvokeInst>(TI)) {
if (Personality == EHPersonality::MSVC_CXX && CleanupPad) {
// Invokes within a cleanuppad for the MSVC++ personality never
@@ -1025,11 +1023,10 @@ void WinEHPrepare::removeImplausibleInstructions(Function &F) {
void WinEHPrepare::cleanupPreparedFunclets(Function &F) {
// Clean-up some of the mess we made by removing useles PHI nodes, trivial
// branches, etc.
- for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) {
- BasicBlock *BB = &*FI++;
- SimplifyInstructionsInBlock(BB);
- ConstantFoldTerminator(BB, /*DeleteDeadConditions=*/true);
- MergeBlockIntoPredecessor(BB);
+ for (BasicBlock &BB : llvm::make_early_inc_range(F)) {
+ SimplifyInstructionsInBlock(&BB);
+ ConstantFoldTerminator(&BB, /*DeleteDeadConditions=*/true);
+ MergeBlockIntoPredecessor(&BB);
}
// We might have some unreachable blocks after cleaning up some impossible
@@ -1109,9 +1106,7 @@ AllocaInst *WinEHPrepare::insertPHILoads(PHINode *PN, Function &F) {
// Otherwise, we have a PHI on a terminator EHPad, and we give up and insert
// loads of the slot before every use.
DenseMap<BasicBlock *, Value *> Loads;
- for (Value::use_iterator UI = PN->use_begin(), UE = PN->use_end();
- UI != UE;) {
- Use &U = *UI++;
+ for (Use &U : llvm::make_early_inc_range(PN->uses())) {
auto *UsingInst = cast<Instruction>(U.getUser());
if (isa<PHINode>(UsingInst) && UsingInst->getParent()->isEHPad()) {
// Use is on an EH pad phi. Leave it alone; we'll insert loads and