Fix another case where LSR was affected by debug info.

llvm-svn: 97865
This commit is contained in:
Dale Johannesen 2010-03-06 02:45:26 +00:00
parent 99d20f83ba
commit 066b8ea590
1 changed files with 12 additions and 1 deletions

View File

@ -1267,8 +1267,19 @@ Value *SCEVExpander::expand(const SCEV *S) {
L = L->getParentLoop())
if (S->isLoopInvariant(L)) {
if (!L) break;
if (BasicBlock *Preheader = L->getLoopPreheader())
if (BasicBlock *Preheader = L->getLoopPreheader()) {
InsertPt = Preheader->getTerminator();
BasicBlock::iterator IP = InsertPt;
// Back past any debug info instructions. Sometimes we inserted
// something earlier before debug info but after any real instructions.
// This should behave the same as if debug info was not present.
while (IP != Preheader->begin()) {
--IP;
if (!isa<DbgInfoIntrinsic>(IP))
break;
InsertPt = IP;
}
}
} else {
// If the SCEV is computable at this level, insert it into the header
// after the PHIs (and after any other instructions that we've inserted