[llvm-branch-commits] [llvm-branch] r81029 - in /llvm/branches/release_26: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/crash.ll

Tanya Lattner tonic at nondot.org
Fri Sep 4 12:26:38 PDT 2009


Author: tbrethou
Date: Fri Sep  4 14:26:38 2009
New Revision: 81029

URL: http://llvm.org/viewvc/llvm-project?rev=81029&view=rev
Log:
Merge 80768 from mainline.
fix PR4815: some cases where DeleteDeadInstruction can delete
the instruction BBI points to.

Added:
    llvm/branches/release_26/test/Transforms/DeadStoreElimination/crash.ll
      - copied unchanged from r80768, llvm/trunk/test/Transforms/DeadStoreElimination/crash.ll
Modified:
    llvm/branches/release_26/lib/Transforms/Scalar/DeadStoreElimination.cpp

Modified: llvm/branches/release_26/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_26/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=81029&r1=81028&r2=81029&view=diff

==============================================================================
--- llvm/branches/release_26/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/branches/release_26/lib/Transforms/Scalar/DeadStoreElimination.cpp Fri Sep  4 14:26:38 2009
@@ -84,7 +84,7 @@
 
   bool MadeChange = false;
   
-  // Do a top-down walk on the BB
+  // Do a top-down walk on the BB.
   for (BasicBlock::iterator BBI = BB.begin(), BBE = BB.end(); BBI != BBE; ) {
     Instruction *Inst = BBI++;
     
@@ -125,7 +125,10 @@
         DeleteDeadInstruction(DepStore);
         NumFastStores++;
         MadeChange = true;
-        
+
+        // DeleteDeadInstruction can delete the current instruction in loop
+        // cases, reset BBI.
+        BBI = Inst;
         if (BBI != BB.begin())
           --BBI;
         continue;
@@ -136,8 +139,15 @@
     if (LoadInst *DepLoad = dyn_cast<LoadInst>(InstDep.getInst())) {
       if (SI->getPointerOperand() == DepLoad->getPointerOperand() &&
           SI->getOperand(0) == DepLoad) {
+        // DeleteDeadInstruction can delete the current instruction.  Save BBI
+        // in case we need it.
+        WeakVH NextInst(BBI);
+        
         DeleteDeadInstruction(SI);
-        if (BBI != BB.begin())
+        
+        if (NextInst == 0)  // Next instruction deleted.
+          BBI = BB.begin();
+        else if (BBI != BB.begin())  // Revisit this instruction if possible.
           --BBI;
         NumFastStores++;
         MadeChange = true;





More information about the llvm-branch-commits mailing list