mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 05:24:01 +00:00
DebugInfo: Lazily attach definition attributes to definitions.
This is a precursor to fixing inlined debug info where the concrete, out-of-line definition may preceed any inlined usage. To cope with this, the attributes that may appear on the concrete definition or the abstract definition are delayed until the end of the module. Then, if an abstract definition was created, it is referenced (and no other attributes are added to the out-of-line definition), otherwise the attributes are added directly to the out-of-line definition. In a couple of cases this causes not just reordering of attributes, but reordering of types. When the creation of the attribute is delayed, if that creation would create a type (such as for a DW_AT_type attribute) then other top level DIEs may've been constructed during the delay, causing the referenced type to be created and added after those intervening DIEs. In the extreme case, in cross-cu-inlining.ll, this actually causes the DW_TAG_basic_type for "int" to move from one CU to another. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209674 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -806,6 +806,25 @@ void DwarfDebug::beginModule() {
|
||||
SectionMap[Asm->getObjFileLowering().getTextSection()];
|
||||
}
|
||||
|
||||
void DwarfDebug::finishSubprogramDefinitions() {
|
||||
const Module *M = MMI->getModule();
|
||||
|
||||
NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
|
||||
for (MDNode *N : CU_Nodes->operands()) {
|
||||
DICompileUnit TheCU(N);
|
||||
// Construct subprogram DIE and add variables DIEs.
|
||||
DwarfCompileUnit *SPCU =
|
||||
static_cast<DwarfCompileUnit *>(CUMap.lookup(TheCU));
|
||||
DIArray Subprograms = TheCU.getSubprograms();
|
||||
for (unsigned i = 0, e = Subprograms.getNumElements(); i != e; ++i) {
|
||||
DISubprogram SP(Subprograms.getElement(i));
|
||||
if (DIE *D = SPCU->getDIE(SP))
|
||||
SPCU->applySubprogramAttributes(SP, *D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Collect info for variables that were optimized out.
|
||||
void DwarfDebug::collectDeadVariables() {
|
||||
const Module *M = MMI->getModule();
|
||||
@ -847,6 +866,8 @@ void DwarfDebug::finalizeModuleInfo() {
|
||||
// Collect info for variables that were optimized out.
|
||||
collectDeadVariables();
|
||||
|
||||
finishSubprogramDefinitions();
|
||||
|
||||
// Handle anything that needs to be done on a per-unit basis after
|
||||
// all other generation.
|
||||
for (const auto &TheU : getUnits()) {
|
||||
|
Reference in New Issue
Block a user