summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2015-04-16 00:02:04 +0000
committerReid Kleckner <reid@kleckner.net>2015-04-16 00:02:04 +0000
commit8676214025efa617bf8e6fb6855c63ba74e277a8 (patch)
tree7fb8fa0d318d11c66842e96080f503070d0176d5 /llvm/lib/CodeGen
parentae9bac3366ca37a0a21e0a49151be4281199c6ff (diff)
downloadbcm5719-llvm-8676214025efa617bf8e6fb6855c63ba74e277a8.tar.gz
bcm5719-llvm-8676214025efa617bf8e6fb6855c63ba74e277a8.zip
[SEH] Deal with users of the old lpad for SEH catch-all blocks
The way we split SEH catch-all blocks can leave some dead EH values behind at -O0. Try to remove them, and if we fail, replace them all with undef. Fixes a crash when removing the old unreachable landingpad which is still used by extractvalue instructions in the catch-all block. llvm-svn: 235061
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/WinEHPrepare.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp
index afe26ff8224..4b0ce21111b 100644
--- a/llvm/lib/CodeGen/WinEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WinEHPrepare.cpp
@@ -433,6 +433,10 @@ bool WinEHPrepare::prepareExceptionHandlers(
Invoke->setUnwindDest(NewLPadBB);
}
+ // If anyone is still using the old landingpad value, just give them undef
+ // instead. The eh pointer and selector values are not real.
+ LPad->replaceAllUsesWith(UndefValue::get(LPad->getType()));
+
// Replace the mapping of any nested landing pad that previously mapped
// to this landing pad with a referenced to the cloned version.
for (auto &LPadPair : NestedLPtoOriginalLP) {
@@ -636,6 +640,11 @@ void WinEHPrepare::promoteLandingPadValues(LandingPadInst *LPad) {
PromoteMemToReg(EHAllocas, *DT);
EHAllocas.clear();
}
+
+ // After promotion, some extracts may be trivially dead. Remove them.
+ SmallVector<Value *, 4> Users(LPad->user_begin(), LPad->user_end());
+ for (auto *U : Users)
+ RecursivelyDeleteTriviallyDeadInstructions(U);
}
void WinEHPrepare::completeNestedLandingPad(Function *ParentFn,
OpenPOWER on IntegriCloud