summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Kaylor <andrew.kaylor@intel.com>2015-03-27 22:31:12 +0000
committerAndrew Kaylor <andrew.kaylor@intel.com>2015-03-27 22:31:12 +0000
commitf7118ae810fd50922c2d4d05404641658f80496f (patch)
tree25ce74a61c0ef2f6be037138b18fe1444e8583b9
parenta2ddf07f259e2ad4e1237b42a7317f60bd42cd74 (diff)
downloadbcm5719-llvm-f7118ae810fd50922c2d4d05404641658f80496f.tar.gz
bcm5719-llvm-f7118ae810fd50922c2d4d05404641658f80496f.zip
Fixing a bug with optimized catch-all handlers in WinEHPrepare
llvm-svn: 233439
-rw-r--r--llvm/lib/CodeGen/WinEHPrepare.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp
index 3f9aaec366e..e35b94f1d36 100644
--- a/llvm/lib/CodeGen/WinEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WinEHPrepare.cpp
@@ -126,6 +126,7 @@ public:
return mapIfEHLoad(Load, SelectorStores, SelectorStoreAddrs);
}
+ bool isOriginLandingPadBlock(const BasicBlock *BB) const;
bool isLandingPadSpecificInst(const Instruction *Inst) const;
void remapSelector(ValueToValueMapTy &VMap, Value *MappedValue) const;
@@ -840,6 +841,10 @@ void LandingPadMap::mapLandingPad(const LandingPadInst *LPad) {
}
}
+bool LandingPadMap::isOriginLandingPadBlock(const BasicBlock *BB) const {
+ return BB->getLandingPadInst() == OriginLPad;
+}
+
bool LandingPadMap::isLandingPadSpecificInst(const Instruction *Inst) const {
if (Inst == OriginLPad)
return true;
@@ -981,11 +986,12 @@ WinEHCatchDirector::handleEndCatch(ValueToValueMapTy &VMap,
// The end catch call can occur in one of two places: either in a
// landingpad block that is part of the catch handlers exception mechanism,
- // or at the end of the catch block. If it occurs in a landing pad, we must
- // skip it and continue so that the landing pad gets cloned.
- // FIXME: This case isn't fully supported yet and shouldn't turn up in any
- // of the test cases until it is.
- if (IntrinCall->getParent()->isLandingPad())
+ // or at the end of the catch block. However, a catch-all handler may call
+ // end catch from the original landing pad. If the call occurs in a nested
+ // landing pad block, we must skip it and continue so that the landing pad
+ // gets cloned.
+ auto *ParentBB = IntrinCall->getParent();
+ if (ParentBB->isLandingPad() && !LPadMap.isOriginLandingPadBlock(ParentBB))
return CloningDirector::SkipInstruction;
// If an end catch occurs anywhere else the next instruction should be an
@@ -1475,6 +1481,9 @@ CleanupHandler *WinEHPrepare::findCleanupHandler(BasicBlock *StartBB,
continue;
if (Inst == Branch)
continue;
+ // This can happen with a catch-all handler.
+ if (match(Inst, m_Intrinsic<Intrinsic::eh_begincatch>()))
+ return nullptr;
if (match(Inst, m_Intrinsic<Intrinsic::eh_endcatch>()))
continue;
// Anything else makes this interesting cleanup code.
OpenPOWER on IntegriCloud