diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2014-09-02 16:22:00 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2014-09-02 16:22:00 +0000 |
| commit | 49428105aa7379619056f735c5b729c0fe41fe99 (patch) | |
| tree | 69aedd2b2714aea168a8372d38d6538ea5687bbf /llvm/lib/Transforms/Scalar/LICM.cpp | |
| parent | 729b12ede3201bd2e78c24bd739884d3bb4cd87d (diff) | |
| download | bcm5719-llvm-49428105aa7379619056f735c5b729c0fe41fe99.tar.gz bcm5719-llvm-49428105aa7379619056f735c5b729c0fe41fe99.zip | |
LICM: Don't crash when an instruction is used by an unreachable BB
Summary:
BBs might contain non-LCSSA'd values after the LCSSA pass is run if they
are unreachable from the entry block.
Normally, the users of the instruction would be PHIs but the unreachable
BBs have normal users; rewrite their uses to be undef values.
An alternative fix could involve fixing this at LCSSA but that would
require this invariant to hold after subsequent transforms. If a BB
created an unreachable block, they would be in violation of this.
This fixes PR19798.
Differential Revision: http://reviews.llvm.org/D5146
llvm-svn: 216911
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LICM.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LICM.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index e41a02d5f12..d387b56689a 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -597,8 +597,13 @@ void LICM::sink(Instruction &I) { // PHI nodes in exit blocks due to LCSSA form. Just RAUW them with clones of // the instruction. while (!I.use_empty()) { + Instruction *User = I.user_back(); + if (!DT->isReachableFromEntry(User->getParent())) { + User->replaceUsesOfWith(&I, UndefValue::get(I.getType())); + continue; + } // The user must be a PHI node. - PHINode *PN = cast<PHINode>(I.user_back()); + PHINode *PN = cast<PHINode>(User); BasicBlock *ExitBlock = PN->getParent(); assert(ExitBlockSet.count(ExitBlock) && |

