summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/WinEHPrepare.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/WinEHPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/WinEHPrepare.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp
index 7ad84734203..0b16a113640 100644
--- a/llvm/lib/CodeGen/WinEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WinEHPrepare.cpp
@@ -838,17 +838,11 @@ void WinEHPrepare::cloneCommonBlocks(Function &F) {
for (auto &BBMapping : Orig2Clone) {
BasicBlock *OldBlock = BBMapping.first;
BasicBlock *NewBlock = BBMapping.second;
- for (Instruction &OldI : *OldBlock) {
- auto *OldPN = dyn_cast<PHINode>(&OldI);
- if (!OldPN)
- break;
- UpdatePHIOnClonedBlock(OldPN, /*IsForOldBlock=*/true);
+ for (PHINode &OldPN : OldBlock->phis()) {
+ UpdatePHIOnClonedBlock(&OldPN, /*IsForOldBlock=*/true);
}
- for (Instruction &NewI : *NewBlock) {
- auto *NewPN = dyn_cast<PHINode>(&NewI);
- if (!NewPN)
- break;
- UpdatePHIOnClonedBlock(NewPN, /*IsForOldBlock=*/false);
+ for (PHINode &NewPN : NewBlock->phis()) {
+ UpdatePHIOnClonedBlock(&NewPN, /*IsForOldBlock=*/false);
}
}
@@ -858,17 +852,13 @@ void WinEHPrepare::cloneCommonBlocks(Function &F) {
BasicBlock *OldBlock = BBMapping.first;
BasicBlock *NewBlock = BBMapping.second;
for (BasicBlock *SuccBB : successors(NewBlock)) {
- for (Instruction &SuccI : *SuccBB) {
- auto *SuccPN = dyn_cast<PHINode>(&SuccI);
- if (!SuccPN)
- break;
-
+ for (PHINode &SuccPN : SuccBB->phis()) {
// Ok, we have a PHI node. Figure out what the incoming value was for
// the OldBlock.
- int OldBlockIdx = SuccPN->getBasicBlockIndex(OldBlock);
+ int OldBlockIdx = SuccPN.getBasicBlockIndex(OldBlock);
if (OldBlockIdx == -1)
break;
- Value *IV = SuccPN->getIncomingValue(OldBlockIdx);
+ Value *IV = SuccPN.getIncomingValue(OldBlockIdx);
// Remap the value if necessary.
if (auto *Inst = dyn_cast<Instruction>(IV)) {
@@ -877,7 +867,7 @@ void WinEHPrepare::cloneCommonBlocks(Function &F) {
IV = I->second;
}
- SuccPN->addIncoming(IV, NewBlock);
+ SuccPN.addIncoming(IV, NewBlock);
}
}
}
OpenPOWER on IntegriCloud