summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-09-12 19:17:09 +0000
committerChris Lattner <sabre@nondot.org>2006-09-12 19:17:09 +0000
commit1d7ec20a4dd576dd513ff282cb0f1577607a97d1 (patch)
tree480430493bb559080f18d72bfcfb11312144ac41 /llvm/lib/Transforms
parent726bc70c438591ffe73e1e653aac6f9bcabe7d68 (diff)
downloadbcm5719-llvm-1d7ec20a4dd576dd513ff282cb0f1577607a97d1.tar.gz
bcm5719-llvm-1d7ec20a4dd576dd513ff282cb0f1577607a97d1.zip
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 llvm-svn: 30275
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LICM.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index a24b366e8d9..7ca9be01359 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud