Skip to content

Commit b813433

Browse files
pratikasharsys_zuul
authored andcommitted
Make IGC emit DW_AT_abstract_origin for inlined DW_TAG_lexical_block
constructs. Change-Id: Ie98bc2bb5f99b8f63e338a2856a601727905f7ff
1 parent dcac073 commit b813433

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

IGC/Compiler/DebugInfo/DwarfDebug.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,21 +473,39 @@ bool DwarfDebug::isLexicalScopeDIENull(LexicalScope* Scope)
473473
}
474474

475475
// Construct new DW_TAG_lexical_block for this scope and attach
476-
// DW_AT_low_pc/DW_AT_high_pc labels as well as DW_AT_INTEL_simd_width
476+
// DW_AT_low_pc/DW_AT_high_pc labels as well as DW_AT_INTEL_simd_width.
477+
// Also add DW_AT_abstract_origin when lexical scope is from inlined code.
477478
DIE* DwarfDebug::constructLexicalScopeDIE(CompileUnit* TheCU, LexicalScope* Scope)
478479
{
479480
if (isLexicalScopeDIENull(Scope))
480481
return 0;
481482

482483
DIE* ScopeDIE = new DIE(dwarf::DW_TAG_lexical_block);
483484
if (Scope->isAbstractScope())
485+
{
486+
AbsLexicalScopeDIEMap.insert(std::make_pair(Scope, ScopeDIE));
484487
return ScopeDIE;
488+
}
485489

486490
const SmallVectorImpl<InsnRange>& Ranges = Scope->getRanges();
487491
IGC_ASSERT_MESSAGE(Ranges.empty() == false, "LexicalScope does not have instruction markers!");
488492

489493
if (m_pModule->isDirectElfInput)
490494
{
495+
if (Scope->getInlinedAt())
496+
{
497+
auto abstractScope = LScopes.findAbstractScope(dyn_cast_or_null<DILocalScope>(Scope->getScopeNode()));
498+
if (abstractScope)
499+
{
500+
auto AbsDIE = AbsLexicalScopeDIEMap.lookup(abstractScope);
501+
if (AbsDIE)
502+
{
503+
// Point to corresponding abstract instance of DW_TAG_lexical_block
504+
TheCU->addDIEEntry(ScopeDIE, dwarf::DW_AT_abstract_origin, AbsDIE);
505+
}
506+
}
507+
}
508+
491509
if (IGC_IS_FLAG_ENABLED(EmitDebugRanges))
492510
{
493511
encodeRange(TheCU, ScopeDIE, &Ranges);

IGC/Compiler/DebugInfo/DwarfDebug.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ namespace IGC
394394

395395
llvm::DenseMap<VISAModule*, llvm::Function*> VISAModToFunc;
396396

397+
llvm::DenseMap<LexicalScope*, DIE*> AbsLexicalScopeDIEMap;
398+
397399
private:
398400

399401
void addScopeVariable(::IGC::LexicalScope* LS, DbgVariable* Var);

0 commit comments

Comments
 (0)