From: Dan Gohman Date: Sun, 14 Feb 2010 03:12:47 +0000 (+0000) Subject: In rememberInstruction, if the value being remembered is the X-Git-Tag: android-x86-6.0-r1~1003^2~9825 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1d826a76f591afea445489b9a5485c345e66bf87;p=android-x86%2Fexternal-llvm.git In rememberInstruction, if the value being remembered is the current insertion point, advance the current insertion point. This avoids a use-before-def situation in a testcase extracted from clang which is difficult to reduce to a reasonable-sized regression test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96151 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h index a9a70cbbb47..303bc1e20a7 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpander.h +++ b/include/llvm/Analysis/ScalarEvolutionExpander.h @@ -168,9 +168,7 @@ namespace llvm { return S->getValue(); } - void rememberInstruction(Value *I) { - if (!PostIncLoop) InsertedValues.insert(I); - } + void rememberInstruction(Value *I); Value *expandAddRecExprLiterally(const SCEVAddRecExpr *); PHINode *getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized, diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index 5de55fed482..88c22b16038 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -1075,6 +1075,20 @@ Value *SCEVExpander::expand(const SCEV *S) { return V; } +void SCEVExpander::rememberInstruction(Value *I) { + if (!PostIncLoop) + InsertedValues.insert(I); + + // If we just claimed an existing instruction and that instruction had + // been the insert point, adjust the insert point forward so that + // subsequently inserted code will be dominated. + if (Builder.GetInsertPoint() == I) { + BasicBlock::iterator It = cast(I); + do { ++It; } while (isInsertedInstruction(It)); + Builder.SetInsertPoint(Builder.GetInsertBlock(), It); + } +} + /// getOrInsertCanonicalInductionVariable - This method returns the /// canonical induction variable of the specified type for the specified /// loop (inserting one if there is none). A canonical induction variable