Skip to content

Commit 7cb007a

Browse files
pratikashargfxbot
authored andcommitted
Skip emission of relocation in debug_info section
Change-Id: I2742064c2a867c2dec763436dd4638967698f6f8
1 parent 16295e9 commit 7cb007a

File tree

3 files changed

+37
-21
lines changed

3 files changed

+37
-21
lines changed

IGC/Compiler/DebugInfo/DwarfDebug.cpp

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,18 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(CompileUnit *SPCU, DISubprogram* SP)
282282
}
283283

284284
#if 1
285-
SPCU->addLabelAddress(SPDie, dwarf::DW_AT_low_pc,
286-
Asm->GetTempSymbol("func_begin", m_pModule->GetFunctionNumber(SP->getName().data())));
287-
SPCU->addLabelAddress(SPDie, dwarf::DW_AT_high_pc,
288-
Asm->GetTempSymbol("func_end", m_pModule->GetFunctionNumber(SP->getName().data())));
285+
if (m_pModule->isDirectElfInput)
286+
{
287+
SPCU->addUInt(SPDie, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, lowPc);
288+
SPCU->addUInt(SPDie, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr, highPc);
289+
}
290+
else
291+
{
292+
SPCU->addLabelAddress(SPDie, dwarf::DW_AT_low_pc,
293+
Asm->GetTempSymbol("func_begin", m_pModule->GetFunctionNumber(SP->getName().data())));
294+
SPCU->addLabelAddress(SPDie, dwarf::DW_AT_high_pc,
295+
Asm->GetTempSymbol("func_end", m_pModule->GetFunctionNumber(SP->getName().data())));
296+
}
289297
#else
290298
// Following existed before supporting stack calls. GetFunctionNumber() was hard
291299
// coded to return 0 always so for single function this worked. With stackcall
@@ -630,32 +638,35 @@ CompileUnit *DwarfDebug::constructCompileUnit(DICompileUnit* DIUnit)
630638
Asm->EmitLabel(ModuleBeginSym);
631639
// 2.17.1 requires that we use DW_AT_low_pc for a single entry point
632640
// into an entity. We're using 0 (or a NULL label) for this.
633-
NewCU->addLabelAddress(Die, dwarf::DW_AT_low_pc, ModuleBeginSym);
641+
634642
if (m_pModule->isDirectElfInput)
635643
{
636644
auto highPC = m_pModule->getUnpaddedProgramSize();
645+
NewCU->addUInt(Die, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, 0);
637646
NewCU->addUInt(Die, dwarf::DW_AT_high_pc, Optional<dwarf::Form>(), highPC);
647+
648+
// DW_AT_stmt_list is a offset of line number information for this
649+
// compile unit in debug_line section. For split dwarf this is
650+
// left in the skeleton CU and so not included.
651+
// The line table entries are not always emitted in assembly, so it
652+
// is not okay to use line_table_start here.
653+
NewCU->addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset, 0);
638654
}
639655
else
640656
{
657+
NewCU->addLabelAddress(Die, dwarf::DW_AT_low_pc, ModuleBeginSym);
641658
NewCU->addLabelAddress(Die, dwarf::DW_AT_high_pc, ModuleEndSym);
642-
}
643-
644-
// Define start line table label for each Compile Unit.
645-
MCSymbol *LineTableStartSym = Asm->GetTempSymbol("line_table_start", NewCU->getUniqueID());
646-
Asm->SetMCLineTableSymbol(LineTableStartSym, NewCU->getUniqueID());
647659

648-
// Use a single line table if we are using .loc and generating assembly.
649-
bool UseTheFirstCU = (NewCU->getUniqueID() == 0);
660+
// Define start line table label for each Compile Unit.
661+
MCSymbol *LineTableStartSym = Asm->GetTempSymbol("line_table_start", NewCU->getUniqueID());
662+
Asm->SetMCLineTableSymbol(LineTableStartSym, NewCU->getUniqueID());
650663

651-
652-
// DW_AT_stmt_list is a offset of line number information for this
653-
// compile unit in debug_line section. For split dwarf this is
654-
// left in the skeleton CU and so not included.
655-
// The line table entries are not always emitted in assembly, so it
656-
// is not okay to use line_table_start here.
657-
NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset,
664+
// Use a single line table if we are using .loc and generating assembly.
665+
bool UseTheFirstCU = (NewCU->getUniqueID() == 0);
666+
NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset,
658667
UseTheFirstCU ? Asm->GetTempSymbol("section_line") : LineTableStartSym);
668+
}
669+
659670
// If we're using split dwarf the compilation dir is going to be in the
660671
// skeleton CU and so we don't need to duplicate it here.
661672
if (!CompilationDir.empty())
@@ -1764,8 +1775,7 @@ void DwarfDebug::emitDIE(DIE *Die)
17641775
}
17651776
case dwarf::DW_AT_ranges:
17661777
// DW_AT_range Value encodes offset in debug_range section.
1767-
Asm->EmitLabelPlusOffset(DwarfDebugRangeSectionSym,
1768-
cast<DIEInteger>(Values[i])->getValue(), 4);
1778+
Values[i]->EmitValue(Asm, Form);
17691779
break;
17701780
case dwarf::DW_AT_location:
17711781
if (DIELabel *L = dyn_cast<DIELabel>(Values[i]))

IGC/Compiler/DebugInfo/DwarfDebug.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ namespace IGC
578578
{
579579
return &DISPToFunction;
580580
}
581+
582+
unsigned int lowPc = 0, highPc = 0;
581583
};
582584
} // namespace IGC
583585

IGC/Compiler/DebugInfo/VISADebugEmitter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ void DebugEmitter::Finalize(void *&pBuffer, unsigned int &size, bool finalize)
215215
std::vector<std::pair<unsigned int, unsigned int>> GenISAToVISAIndex;
216216
unsigned int subEnd = m_pVISAModule->GetCurrentVISAId();
217217
unsigned int prevLastGenOff = lastGenOff;
218+
m_pDwarfDebug->lowPc = lastGenOff;
218219

219220
for (auto item : m_pVISAModule->GenISAToVISAIndex)
220221
{
@@ -269,8 +270,11 @@ void DebugEmitter::Finalize(void *&pBuffer, unsigned int &size, bool finalize)
269270
for (unsigned int i = pc; i != m_pVISAModule->getUnpaddedProgramSize(); i++)
270271
{
271272
m_pStreamEmitter->EmitInt8(((unsigned char*)genxISA)[i]);
273+
lastGenOff++;
272274
}
273275
}
276+
277+
m_pDwarfDebug->highPc = lastGenOff;
274278
}
275279
else
276280
{

0 commit comments

Comments
 (0)