diff options
author | Chris Lattner <sabre@nondot.org> | 2005-10-27 17:13:11 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-10-27 17:13:11 +0000 |
commit | 108e902aebd7d8d09f29dc62fa13c155d2d8b6c2 (patch) | |
tree | 426b0c3c81c421ff9c0bdbe0fab37c42644e1a32 | |
parent | cbbc6b74e357afbf8fb37fdeb177ed78021092d3 (diff) | |
download | external_llvm-108e902aebd7d8d09f29dc62fa13c155d2d8b6c2.zip external_llvm-108e902aebd7d8d09f29dc62fa13c155d2d8b6c2.tar.gz external_llvm-108e902aebd7d8d09f29dc62fa13c155d2d8b6c2.tar.bz2 |
Do not sink any instruction with side effects, including vaarg. This fixes
PR640
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24046 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 7db409d..4aab096 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -5717,8 +5717,8 @@ void InstCombiner::removeFromWorkList(Instruction *I) { 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 @@ static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) { // 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()) |