diff options
| author | Dale Johannesen <dalej@apple.com> | 2009-03-03 01:09:07 +0000 |
|---|---|---|
| committer | Dale Johannesen <dalej@apple.com> | 2009-03-03 01:09:07 +0000 |
| commit | e1bb2f86f9db3bed7db9a8f1304308af0b39dc85 (patch) | |
| tree | 241166e96cbbe921a4207938a1fde4219e5d6699 /llvm/lib | |
| parent | f3833d70bed4d60ef4dec4d1e685c5e1ce3f5fed (diff) | |
| download | bcm5719-llvm-e1bb2f86f9db3bed7db9a8f1304308af0b39dc85.tar.gz bcm5719-llvm-e1bb2f86f9db3bed7db9a8f1304308af0b39dc85.zip | |
When sinking an insn in InstCombine bring its debug
info with it.
Don't count debug info insns against the scan maximum
in FindAvailableLoadedValue (lest they affect codegen).
llvm-svn: 65910
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 1 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | 27 |
2 files changed, 26 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 7ddbb4ca7cb..e0d3ac4d428 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -12374,6 +12374,7 @@ static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) { BasicBlock::iterator InsertPos = DestBlock->getFirstNonPHI(); + CopyPrecedingStopPoint(I, InsertPos); I->moveBefore(InsertPos); ++NumSunkInst; return true; diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp index 7b633b20077..875de559b76 100644 --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -15,6 +15,7 @@ #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Function.h" #include "llvm/Instructions.h" +#include "llvm/IntrinsicInst.h" #include "llvm/Constant.h" #include "llvm/Type.h" #include "llvm/Analysis/AliasAnalysis.h" @@ -471,11 +472,18 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB, } while (ScanFrom != ScanBB->begin()) { + // We must ignore debug info directives when counting (otherwise they + // would affect codegen). + Instruction *Inst = --ScanFrom; + if (isa<DbgInfoIntrinsic>(Inst)) + continue; + // Restore ScanFrom to expected value in case next test succeeds + ScanFrom++; + // Don't scan huge blocks. if (MaxInstsToScan-- == 0) return 0; - Instruction *Inst = --ScanFrom; - + --ScanFrom; // If this is a load of Ptr, the loaded value is available. if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) if (AreEquivalentAddressValues(LI->getOperand(0), Ptr)) @@ -523,3 +531,18 @@ Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB, // block. return 0; } + +/// CopyPrecedingStopPoint - If I is immediately preceded by a StopPoint, +/// make a copy of the stoppoint before InsertPos (presumably before copying +/// or moving I). +void llvm::CopyPrecedingStopPoint(Instruction *I, + BasicBlock::iterator InsertPos) { + if (I != I->getParent()->begin()) { + BasicBlock::iterator BBI = I; --BBI; + if (DbgStopPointInst *DSPI = dyn_cast<DbgStopPointInst>(BBI)) { + DbgStopPointInst *newDSPI = + reinterpret_cast<DbgStopPointInst*>(DSPI->clone()); + newDSPI->insertBefore(InsertPos); + } + } +} |

