summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/BranchFolding.cpp
diff options
context:
space:
mode:
authorAndrew Kaylor <andrew.kaylor@intel.com>2015-12-03 18:55:28 +0000
committerAndrew Kaylor <andrew.kaylor@intel.com>2015-12-03 18:55:28 +0000
commit9efb2332e25477218352323f2592c6a2e2e9739c (patch)
tree4902b8dec80d9e168723e111e8a53497cb6929d5 /llvm/lib/CodeGen/BranchFolding.cpp
parenta1b79aeab982755b7943f52631877087393b24ac (diff)
downloadbcm5719-llvm-9efb2332e25477218352323f2592c6a2e2e9739c.tar.gz
bcm5719-llvm-9efb2332e25477218352323f2592c6a2e2e9739c.zip
[WinEH] Avoid infinite loop in BranchFolding for multiple single block funclets
Differential Revision: http://reviews.llvm.org/D14996 llvm-svn: 254629
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index 54d92ad67a9..c6a6476747e 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -1564,6 +1564,14 @@ ReoptimizeBlock:
// removed, move this block to the end of the function.
MachineBasicBlock *PrevTBB = nullptr, *PrevFBB = nullptr;
SmallVector<MachineOperand, 4> PrevCond;
+ // We're looking for cases where PrevBB could possibly fall through to
+ // FallThrough, but if FallThrough is an EH pad that wouldn't be useful
+ // so here we skip over any EH pads so we might have a chance to find
+ // a branch target from PrevBB.
+ while (FallThrough != MF.end() && FallThrough->isEHPad())
+ ++FallThrough;
+ // Now check to see if the current block is sitting between PrevBB and
+ // a block to which it could fall through.
if (FallThrough != MF.end() &&
!TII->AnalyzeBranch(PrevBB, PrevTBB, PrevFBB, PrevCond, true) &&
PrevBB.isSuccessor(&*FallThrough)) {
OpenPOWER on IntegriCloud