[PATCH] D95019: [ConstantHoisting] Fix bug where constant materialization could insert into EH pad
Michael Holman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 21 13:57:22 PST 2021
Holman updated this revision to Diff 318310.
Holman added a comment.
Fix shadowing bug.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95019/new/
https://reviews.llvm.org/D95019
Files:
llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
Index: llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
+++ llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
@@ -185,13 +185,20 @@
// We can't insert directly before a phi node or an eh pad. Insert before
// the terminator of the incoming or dominating block.
assert(Entry != Inst->getParent() && "PHI or landing pad in entry block!");
- if (Idx != ~0U && isa<PHINode>(Inst))
- return cast<PHINode>(Inst)->getIncomingBlock(Idx)->getTerminator();
+ BasicBlock *InsertionBlock = nullptr;
+ if (Idx != ~0U && isa<PHINode>(Inst)) {
+ InsertionBlock = cast<PHINode>(Inst)->getIncomingBlock(Idx);
+ if (!InsertionBlock->isEHPad()) {
+ return InsertionBlock->getTerminator();
+ }
+ } else {
+ InsertionBlock = Inst->getParent();
+ }
// This must be an EH pad. Iterate over immediate dominators until we find a
// non-EH pad. We need to skip over catchswitch blocks, which are both EH pads
// and terminators.
- auto IDom = DT->getNode(Inst->getParent())->getIDom();
+ auto IDom = DT->getNode(InsertionBlock)->getIDom();
while (IDom->getBlock()->isEHPad()) {
assert(Entry != IDom->getBlock() && "eh pad in entry block");
IDom = IDom->getIDom();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95019.318310.patch
Type: text/x-patch
Size: 1315 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210121/d67c1f3c/attachment.bin>
More information about the llvm-commits
mailing list