diff options
author | Chris Lattner <sabre@nondot.org> | 2006-09-12 19:17:09 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-09-12 19:17:09 +0000 |
commit | 92f7365740e9a116c59a8d33e636ebf6e4699301 (patch) | |
tree | 96ab0a2618fc259c4aba535080af7860fff7aa2d | |
parent | 431a80ade759d26976556c8c5ced4f5c1012702c (diff) | |
download | llvm-92f7365740e9a116c59a8d33e636ebf6e4699301.tar.gz llvm-92f7365740e9a116c59a8d33e636ebf6e4699301.tar.bz2 llvm-92f7365740e9a116c59a8d33e636ebf6e4699301.tar.xz |
An sinkable instruction may exist with uses, if those uses are in dead blocks.
Handle this. This fixes PR908 and Transforms/LICM/2006-09-12-DeadUserOfSunkInstr.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30275 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/LICM.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index a24b366e8d..7ca9be0135 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -447,6 +447,8 @@ void LICM::sink(Instruction &I) { if (!isExitBlockDominatedByBlockInLoop(ExitBlocks[0], I.getParent())) { // Instruction is not used, just delete it. CurAST->deleteValue(&I); + if (!I.use_empty()) // If I has users in unreachable blocks, eliminate. + I.replaceAllUsesWith(UndefValue::get(I.getType())); I.eraseFromParent(); } else { // Move the instruction to the start of the exit block, after any PHI @@ -460,6 +462,8 @@ void LICM::sink(Instruction &I) { } else if (ExitBlocks.size() == 0) { // The instruction is actually dead if there ARE NO exit blocks. CurAST->deleteValue(&I); + if (!I.use_empty()) // If I has users in unreachable blocks, eliminate. + I.replaceAllUsesWith(UndefValue::get(I.getType())); I.eraseFromParent(); } else { // Otherwise, if we have multiple exits, use the PromoteMem2Reg function to |