[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LICM.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Sep 12 12:17:23 PDT 2006



Changes in directory llvm/lib/Transforms/Scalar:

LICM.cpp updated: 1.78 -> 1.79
---
Log message:

An sinkable instruction may exist with uses, if those uses are in dead blocks.
Handle this.  This fixes PR908: http://llvm.org/PR908  and Transforms/LICM/2006-09-12-DeadUserOfSunkInstr.ll



---
Diffs of the changes:  (+4 -0)

 LICM.cpp |    4 ++++
 1 files changed, 4 insertions(+)


Index: llvm/lib/Transforms/Scalar/LICM.cpp
diff -u llvm/lib/Transforms/Scalar/LICM.cpp:1.78 llvm/lib/Transforms/Scalar/LICM.cpp:1.79
--- llvm/lib/Transforms/Scalar/LICM.cpp:1.78	Sun Aug 27 17:42:52 2006
+++ llvm/lib/Transforms/Scalar/LICM.cpp	Tue Sep 12 14:17:09 2006
@@ -447,6 +447,8 @@
     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 @@
   } 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






More information about the llvm-commits mailing list