From 2539e3389361115f5e75e4134bdd123171688ddc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 8 May 2008 17:37:37 +0000 Subject: More than just loads can read from memory: readonly calls like strlen also need to be checked for memory modifying instructions before we can sink them. THis fixes the second half of PR2297. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50860 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index b0ea9f5..772ef63 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -11229,8 +11229,8 @@ 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(I)) { - for (BasicBlock::iterator Scan = LI, E = LI->getParent()->end(); + if (I->mayReadFromMemory()) { + for (BasicBlock::iterator Scan = I, E = I->getParent()->end(); Scan != E; ++Scan) if (Scan->mayWriteToMemory()) return false; @@ -11388,8 +11388,8 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) { } // See if we can trivially sink this instruction to a successor basic block. - // FIXME: Remove GetResultInst test when first class support for aggregates is - // implemented. + // FIXME: Remove GetResultInst test when first class support for aggregates + // is implemented. if (I->hasOneUse() && !isa(I)) { BasicBlock *BB = I->getParent(); BasicBlock *UserParent = cast(I->use_back())->getParent(); -- cgit v1.1