mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-23 02:32:11 +00:00
Attempt to preserve debug line info in LICM; as the comment in the code says, it's hard to pick good line numbers for this transformation, but something is better than nothing.
rdar://9143729 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132215 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b12ae5db89
commit
dda266d4ce
@ -605,13 +605,15 @@ namespace {
|
|||||||
SmallPtrSet<Value*, 4> &PointerMustAliases;
|
SmallPtrSet<Value*, 4> &PointerMustAliases;
|
||||||
SmallVectorImpl<BasicBlock*> &LoopExitBlocks;
|
SmallVectorImpl<BasicBlock*> &LoopExitBlocks;
|
||||||
AliasSetTracker &AST;
|
AliasSetTracker &AST;
|
||||||
|
DebugLoc DL;
|
||||||
public:
|
public:
|
||||||
LoopPromoter(Value *SP,
|
LoopPromoter(Value *SP,
|
||||||
const SmallVectorImpl<Instruction*> &Insts, SSAUpdater &S,
|
const SmallVectorImpl<Instruction*> &Insts, SSAUpdater &S,
|
||||||
SmallPtrSet<Value*, 4> &PMA,
|
SmallPtrSet<Value*, 4> &PMA,
|
||||||
SmallVectorImpl<BasicBlock*> &LEB, AliasSetTracker &ast)
|
SmallVectorImpl<BasicBlock*> &LEB, AliasSetTracker &ast,
|
||||||
|
DebugLoc dl)
|
||||||
: LoadAndStorePromoter(Insts, S, 0, 0), SomePtr(SP),
|
: LoadAndStorePromoter(Insts, S, 0, 0), SomePtr(SP),
|
||||||
PointerMustAliases(PMA), LoopExitBlocks(LEB), AST(ast) {}
|
PointerMustAliases(PMA), LoopExitBlocks(LEB), AST(ast), DL(dl) {}
|
||||||
|
|
||||||
virtual bool isInstInList(Instruction *I,
|
virtual bool isInstInList(Instruction *I,
|
||||||
const SmallVectorImpl<Instruction*> &) const {
|
const SmallVectorImpl<Instruction*> &) const {
|
||||||
@ -632,7 +634,8 @@ namespace {
|
|||||||
BasicBlock *ExitBlock = LoopExitBlocks[i];
|
BasicBlock *ExitBlock = LoopExitBlocks[i];
|
||||||
Value *LiveInValue = SSA.GetValueInMiddleOfBlock(ExitBlock);
|
Value *LiveInValue = SSA.GetValueInMiddleOfBlock(ExitBlock);
|
||||||
Instruction *InsertPos = ExitBlock->getFirstNonPHI();
|
Instruction *InsertPos = ExitBlock->getFirstNonPHI();
|
||||||
new StoreInst(LiveInValue, SomePtr, InsertPos);
|
StoreInst *NewSI = new StoreInst(LiveInValue, SomePtr, InsertPos);
|
||||||
|
NewSI->setDebugLoc(DL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -730,6 +733,12 @@ void LICM::PromoteAliasSet(AliasSet &AS) {
|
|||||||
Changed = true;
|
Changed = true;
|
||||||
++NumPromoted;
|
++NumPromoted;
|
||||||
|
|
||||||
|
// Grab a debug location for the inserted loads/stores; given that the
|
||||||
|
// inserted loads/stores have little relation to the original loads/stores,
|
||||||
|
// this code just arbitrarily picks a location from one, since any debug
|
||||||
|
// location is better than none.
|
||||||
|
DebugLoc DL = LoopUses[0]->getDebugLoc();
|
||||||
|
|
||||||
SmallVector<BasicBlock*, 8> ExitBlocks;
|
SmallVector<BasicBlock*, 8> ExitBlocks;
|
||||||
CurLoop->getUniqueExitBlocks(ExitBlocks);
|
CurLoop->getUniqueExitBlocks(ExitBlocks);
|
||||||
|
|
||||||
@ -737,13 +746,14 @@ void LICM::PromoteAliasSet(AliasSet &AS) {
|
|||||||
SmallVector<PHINode*, 16> NewPHIs;
|
SmallVector<PHINode*, 16> NewPHIs;
|
||||||
SSAUpdater SSA(&NewPHIs);
|
SSAUpdater SSA(&NewPHIs);
|
||||||
LoopPromoter Promoter(SomePtr, LoopUses, SSA, PointerMustAliases, ExitBlocks,
|
LoopPromoter Promoter(SomePtr, LoopUses, SSA, PointerMustAliases, ExitBlocks,
|
||||||
*CurAST);
|
*CurAST, DL);
|
||||||
|
|
||||||
// Set up the preheader to have a definition of the value. It is the live-out
|
// Set up the preheader to have a definition of the value. It is the live-out
|
||||||
// value from the preheader that uses in the loop will use.
|
// value from the preheader that uses in the loop will use.
|
||||||
LoadInst *PreheaderLoad =
|
LoadInst *PreheaderLoad =
|
||||||
new LoadInst(SomePtr, SomePtr->getName()+".promoted",
|
new LoadInst(SomePtr, SomePtr->getName()+".promoted",
|
||||||
Preheader->getTerminator());
|
Preheader->getTerminator());
|
||||||
|
PreheaderLoad->setDebugLoc(DL);
|
||||||
SSA.AddAvailableValue(Preheader, PreheaderLoad);
|
SSA.AddAvailableValue(Preheader, PreheaderLoad);
|
||||||
|
|
||||||
// Rewrite all the loads in the loop and remember all the definitions from
|
// Rewrite all the loads in the loop and remember all the definitions from
|
||||||
|
Loading…
x
Reference in New Issue
Block a user