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

Chris Lattner lattner at cs.uiuc.edu
Tue Jul 27 00:38:42 PDT 2004



Changes in directory llvm/lib/Transforms/Scalar:

LICM.cpp updated: 1.63 -> 1.64

---
Log message:

Fix hoisting of void typed values, e.g. calls


---
Diffs of the changes:  (+13 -7)

Index: llvm/lib/Transforms/Scalar/LICM.cpp
diff -u llvm/lib/Transforms/Scalar/LICM.cpp:1.63 llvm/lib/Transforms/Scalar/LICM.cpp:1.64
--- llvm/lib/Transforms/Scalar/LICM.cpp:1.63	Sat Jun 19 15:23:35 2004
+++ llvm/lib/Transforms/Scalar/LICM.cpp	Tue Jul 27 02:38:32 2004
@@ -462,9 +462,12 @@
     // the value into a stack object to get it to do this.
 
     // Firstly, we create a stack object to hold the value...
-    AllocaInst *AI = new AllocaInst(I.getType(), 0, I.getName(),
-                                   I.getParent()->getParent()->front().begin());
+    AllocaInst *AI = 0;
 
+    if (I.getType() != Type::VoidTy)
+      AI = new AllocaInst(I.getType(), 0, I.getName(),
+                          I.getParent()->getParent()->front().begin());
+    
     // Secondly, insert load instructions for each use of the instruction
     // outside of the loop.
     while (!I.use_empty()) {
@@ -522,12 +525,13 @@
             New = &I;
           } else {
             New = I.clone();
-            New->setName(I.getName()+".le");
+            if (!I.getName().empty())
+              New->setName(I.getName()+".le");
             ExitBlock->getInstList().insert(InsertPt, New);
           }
           
           // Now that we have inserted the instruction, store it into the alloca
-          new StoreInst(New, AI, InsertPt);
+          if (AI) new StoreInst(New, AI, InsertPt);
         }
       }
     }
@@ -539,9 +543,11 @@
     }
       
     // Finally, promote the fine value to SSA form.
-    std::vector<AllocaInst*> Allocas;
-    Allocas.push_back(AI);
-    PromoteMemToReg(Allocas, *DT, *DF, AA->getTargetData());
+    if (AI) {
+      std::vector<AllocaInst*> Allocas;
+      Allocas.push_back(AI);
+      PromoteMemToReg(Allocas, *DT, *DF, AA->getTargetData());
+    }
   }
 }
 





More information about the llvm-commits mailing list