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

Chris Lattner lattner at cs.uiuc.edu
Thu Oct 27 10:13:22 PDT 2005



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.397 -> 1.398
---
Log message:

Do not sink any instruction with side effects, including vaarg.  This fixes
PR640: http://llvm.cs.uiuc.edu/PR640 


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

 InstructionCombining.cpp |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.397 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.398
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.397	Thu Oct 27 01:26:26 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Thu Oct 27 12:13:11 2005
@@ -5717,8 +5717,8 @@
 static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) {
   assert(I->hasOneUse() && "Invariants didn't hold!");
 
-  // Cannot move control-flow-involving instructions.
-  if (isa<PHINode>(I) || isa<InvokeInst>(I) || isa<CallInst>(I)) return false;
+  // Cannot move control-flow-involving, volatile loads, vaarg, etc.
+  if (isa<PHINode>(I) || I->mayWriteToMemory()) return false;
 
   // Do not sink alloca instructions out of the entry block.
   if (isa<AllocaInst>(I) && I->getParent() == &DestBlock->getParent()->front())
@@ -5727,8 +5727,6 @@
   // We can only sink load instructions if there is nothing between the load and
   // the end of block that could change the value.
   if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
-    if (LI->isVolatile()) return false;  // Don't sink volatile loads.
-
     for (BasicBlock::iterator Scan = LI, E = LI->getParent()->end();
          Scan != E; ++Scan)
       if (Scan->mayWriteToMemory())






More information about the llvm-commits mailing list