mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-07 14:33:15 +00:00
Refactor. It is inliner's responsibility to update line number information.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134708 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
549a85138c
commit
2cf158ec4b
@ -418,50 +418,14 @@ void llvm::CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc,
|
|||||||
if (PHINode *PN = dyn_cast<PHINode>(I)) {
|
if (PHINode *PN = dyn_cast<PHINode>(I)) {
|
||||||
// Skip over all PHI nodes, remembering them for later.
|
// Skip over all PHI nodes, remembering them for later.
|
||||||
BasicBlock::const_iterator OldI = BI->begin();
|
BasicBlock::const_iterator OldI = BI->begin();
|
||||||
for (; (PN = dyn_cast<PHINode>(I)); ++I, ++OldI) {
|
for (; (PN = dyn_cast<PHINode>(I)); ++I, ++OldI)
|
||||||
if (I->hasMetadata()) {
|
|
||||||
if (!TheCallDL.isUnknown()) {
|
|
||||||
DebugLoc IDL = I->getDebugLoc();
|
|
||||||
if (!IDL.isUnknown()) {
|
|
||||||
DebugLoc NewDL = UpdateInlinedAtInfo(IDL, TheCallDL,
|
|
||||||
I->getContext());
|
|
||||||
I->setDebugLoc(NewDL);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// The cloned instruction has dbg info but the call instruction
|
|
||||||
// does not have dbg info. Remove dbg info from cloned instruction.
|
|
||||||
I->setDebugLoc(DebugLoc());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PHIToResolve.push_back(cast<PHINode>(OldI));
|
PHIToResolve.push_back(cast<PHINode>(OldI));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME:
|
|
||||||
// FIXME:
|
|
||||||
// FIXME: Unclone all this metadata stuff.
|
|
||||||
// FIXME:
|
|
||||||
// FIXME:
|
|
||||||
|
|
||||||
// Otherwise, remap the rest of the instructions normally.
|
// Otherwise, remap the rest of the instructions normally.
|
||||||
for (; I != NewBB->end(); ++I) {
|
for (; I != NewBB->end(); ++I)
|
||||||
if (I->hasMetadata()) {
|
|
||||||
if (!TheCallDL.isUnknown()) {
|
|
||||||
DebugLoc IDL = I->getDebugLoc();
|
|
||||||
if (!IDL.isUnknown()) {
|
|
||||||
DebugLoc NewDL = UpdateInlinedAtInfo(IDL, TheCallDL,
|
|
||||||
I->getContext());
|
|
||||||
I->setDebugLoc(NewDL);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// The cloned instruction has dbg info but the call instruction
|
|
||||||
// does not have dbg info. Remove dbg info from cloned instruction.
|
|
||||||
I->setDebugLoc(DebugLoc());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RemapInstruction(I, VMap,
|
RemapInstruction(I, VMap,
|
||||||
ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges);
|
ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defer PHI resolution until rest of function is resolved, PHI resolution
|
// Defer PHI resolution until rest of function is resolved, PHI resolution
|
||||||
|
@ -744,6 +744,41 @@ static bool hasLifetimeMarkers(AllocaInst *AI) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// updateInlinedAtInfo - Helper function used by fixupLineNumbers to recursively
|
||||||
|
/// update InlinedAtEntry of a DebugLoc.
|
||||||
|
static DebugLoc updateInlinedAtInfo(const DebugLoc &DL,
|
||||||
|
const DebugLoc &InlinedAtDL,
|
||||||
|
LLVMContext &Ctx) {
|
||||||
|
if (MDNode *IA = DL.getInlinedAt(Ctx)) {
|
||||||
|
DebugLoc NewInlinedAtDL
|
||||||
|
= updateInlinedAtInfo(DebugLoc::getFromDILocation(IA), InlinedAtDL, Ctx);
|
||||||
|
return DebugLoc::get(DL.getLine(), DL.getCol(), DL.getScope(Ctx),
|
||||||
|
NewInlinedAtDL.getAsMDNode(Ctx));
|
||||||
|
}
|
||||||
|
|
||||||
|
return DebugLoc::get(DL.getLine(), DL.getCol(), DL.getScope(Ctx),
|
||||||
|
InlinedAtDL.getAsMDNode(Ctx));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// fixupLineNumbers - Update inlined instructions' line numbers to
|
||||||
|
/// to encode location where these instructions are inlined.
|
||||||
|
static void fixupLineNumbers(Function *Fn, Function::iterator FI,
|
||||||
|
Instruction *TheCall) {
|
||||||
|
DebugLoc TheCallDL = TheCall->getDebugLoc();
|
||||||
|
if (TheCallDL.isUnknown())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (; FI != Fn->end(); ++FI) {
|
||||||
|
for (BasicBlock::iterator BI = FI->begin(), BE = FI->end();
|
||||||
|
BI != BE; ++BI) {
|
||||||
|
DebugLoc DL = BI->getDebugLoc();
|
||||||
|
if (!DL.isUnknown())
|
||||||
|
BI->setDebugLoc(updateInlinedAtInfo(DL, TheCallDL, BI->getContext()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// InlineFunction - This function inlines the called function into the basic
|
// InlineFunction - This function inlines the called function into the basic
|
||||||
// block of the caller. This returns false if it is not possible to inline this
|
// block of the caller. This returns false if it is not possible to inline this
|
||||||
// call. The program is still in a well defined state if this occurs though.
|
// call. The program is still in a well defined state if this occurs though.
|
||||||
@ -846,6 +881,9 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI) {
|
|||||||
// Update the callgraph if requested.
|
// Update the callgraph if requested.
|
||||||
if (IFI.CG)
|
if (IFI.CG)
|
||||||
UpdateCallGraphAfterInlining(CS, FirstNewBlock, VMap, IFI);
|
UpdateCallGraphAfterInlining(CS, FirstNewBlock, VMap, IFI);
|
||||||
|
|
||||||
|
// Update inlined instructions' line number information.
|
||||||
|
fixupLineNumbers(Caller, FirstNewBlock, TheCall);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are any alloca instructions in the block that used to be the entry
|
// If there are any alloca instructions in the block that used to be the entry
|
||||||
|
Loading…
x
Reference in New Issue
Block a user