Skip to content

Commit 39fa377

Browse files
aparshin-inteligcbot
authored andcommitted
debug info is always emitted as an elf
Remove deprecated codepath used for legacy debug info generation
1 parent 2a87f79 commit 39fa377

File tree

14 files changed

+108
-374
lines changed

14 files changed

+108
-374
lines changed

IGC/Compiler/CISACodeGen/DebugInfo.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ bool DebugInfoPass::doFinalization(llvm::Module& M)
4949
bool DebugInfoPass::runOnModule(llvm::Module& M)
5050
{
5151
std::vector<CShader*> units;
52-
bool isOneStepElf = false;
5352

5453
auto isCandidate = [](CShaderProgram* shaderProgram, SIMDMode m, ShaderDispatchMode mode = ShaderDispatchMode::NOT_APPLICABLE)
5554
{
@@ -254,7 +253,6 @@ bool DebugInfoPass::runOnModule(llvm::Module& M)
254253
auto SPDiesToBuild = getSPDiesCollection(functions);
255254
for (auto& m : sortedVISAModules)
256255
{
257-
isOneStepElf |= m.second.second->isDirectElfInput;
258256
m_pDebugEmitter->setCurrentVISA(m.second.second);
259257

260258
if (--size == 0)
@@ -264,11 +262,8 @@ bool DebugInfoPass::runOnModule(llvm::Module& M)
264262
}
265263

266264
// set VISA dbg info to nullptr to indicate 1-step debug is enabled
267-
if (isOneStepElf)
268-
{
269-
currShader->ProgramOutput()->m_debugDataGenISASize = 0;
270-
currShader->ProgramOutput()->m_debugDataGenISA = nullptr;
271-
}
265+
currShader->ProgramOutput()->m_debugDataGenISASize = 0;
266+
currShader->ProgramOutput()->m_debugDataGenISA = nullptr;
272267

273268
if (finalize)
274269
{

IGC/Compiler/CISACodeGen/DriverInfo.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ namespace IGC
188188
/// pick behavior whether we need to keep discarded helper pixels to calculate
189189
/// gradient correctly for sampler or we need to force early out discarded pixels
190190
virtual bool KeepDiscardHelperPixels() const { return false; }
191-
virtual bool SupportElfFormat() const { return false; }
192191

193192
// Choose to support parsing inlined asm instructions on specific platforms
194193
virtual bool SupportInlineAssembly() const { return false; }

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,6 @@ bool EmitPass::runOnFunction(llvm::Function& F)
809809
auto vMod = IGC::ScalarVisaModule::BuildNew(m_currShader, Entry);
810810
IGC::DebugEmitterOpts DebugOpts;
811811
DebugOpts.DebugEnabled = DebugInfoData::hasDebugInfo(m_currShader);
812-
DebugOpts.isDirectElf = vMod->isDirectElfInput;
813812
DebugOpts.UseNewRegisterEncoding = IGC_IS_FLAG_ENABLED(UseNewRegEncoding);
814813
DebugOpts.EnableSIMDLaneDebugging = IGC_IS_FLAG_ENABLED(EnableSIMDLaneDebugging);
815814
DebugOpts.EnableGTLocationDebugging = IGC_IS_FLAG_ENABLED(EnableGTLocationDebugging);

IGC/Compiler/DebugInfo/ScalarVISAModule.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,7 @@ ScalarVisaModule::ScalarVisaModule(CShader* TheShader, llvm::Function *TheFuncti
9595

9696
std::unique_ptr<IGC::VISAModule> ScalarVisaModule::BuildNew(CShader* S, llvm::Function *F)
9797
{
98-
auto n = new ScalarVisaModule(S, F);
99-
100-
if (n->m_pShader->GetContext()->m_DriverInfo.SupportElfFormat() ||
101-
isLineTableOnly(S) ||
102-
IGC_GET_FLAG_VALUE(EnableOneStepElf))
103-
{
104-
n->isDirectElfInput = true;
105-
}
106-
98+
auto* n = new ScalarVisaModule(S, F);
10799
return std::unique_ptr<IGC::VISAModule>(n);
108100
}
109101

IGC/DebugInfo/DwarfCompileUnit.cpp

Lines changed: 35 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -299,21 +299,11 @@ void CompileUnit::addSInt(IGC::DIEBlock* Die, Optional<dwarf::Form> Form, int64_
299299
/// table.
300300
void CompileUnit::addString(DIE* Die, dwarf::Attribute Attribute, StringRef String)
301301
{
302-
if (DD->IsDirectElfInput())
303-
{
304-
// Emit string inlined
305-
auto Str = new (DIEValueAllocator) DIEInlinedString(String);
306-
// Collect all inlined string DIEs to later call dtor
307-
DIEInlinedStrings.push_back(Str);
308-
Die->addValue(Attribute, dwarf::DW_FORM_string, Str);
309-
}
310-
else
311-
{
312-
MCSymbol* Symb = DD->getStringPoolEntry(String);
313-
DIEValue* Value = new (DIEValueAllocator)DIELabel(Symb);
314-
DIEValue* Str = new (DIEValueAllocator)DIEString(Value, String);
315-
Die->addValue(Attribute, dwarf::DW_FORM_strp, Str);
316-
}
302+
// Emit string inlined
303+
auto Str = new (DIEValueAllocator) DIEInlinedString(String);
304+
// Collect all inlined string DIEs to later call dtor
305+
DIEInlinedStrings.push_back(Str);
306+
Die->addValue(Attribute, dwarf::DW_FORM_string, Str);
317307
}
318308

319309
/// addExpr - Add a Dwarf expression attribute data and value.
@@ -2356,32 +2346,23 @@ IGC::DIE* CompileUnit::constructVariableDIE(DbgVariable& DV, bool isScopeAbstrac
23562346
unsigned Offset = DV.getDotDebugLocOffset();
23572347
if (Offset != ~0U)
23582348
{
2359-
if (DD->IsDirectElfInput())
2349+
// Copy over references ranges to DotLocDebugEntries
2350+
if (EmitSettings.EnableRelocation)
23602351
{
2361-
// Copy over references ranges to DotLocDebugEntries
2362-
if (EmitSettings.EnableRelocation)
2363-
{
2364-
// Retrieve correct location value based on Offset.
2365-
// Then attach label corresponding to this offset
2366-
// to DW_AT_location attribute.
2367-
auto LocLabel = DD->CopyDebugLoc(Offset);
2368-
addLabelLoc(VariableDie, dwarf::DW_AT_location, LocLabel);
2369-
}
2370-
else
2371-
{
2372-
Offset = DD->CopyDebugLocNoReloc(Offset);
2373-
addUInt(VariableDie, dwarf::DW_AT_location, dwarf::DW_FORM_sec_offset, Offset);
2374-
}
2375-
if (DV.getDecorations().size() > 0)
2376-
{
2377-
addString(VariableDie, dwarf::DW_AT_description, DV.getDecorations());
2378-
}
2352+
// Retrieve correct location value based on Offset.
2353+
// Then attach label corresponding to this offset
2354+
// to DW_AT_location attribute.
2355+
auto LocLabel = DD->CopyDebugLoc(Offset);
2356+
addLabelLoc(VariableDie, dwarf::DW_AT_location, LocLabel);
23792357
}
23802358
else
23812359
{
2382-
addLabel(VariableDie, dwarf::DW_AT_location,
2383-
DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset : dwarf::DW_FORM_data4,
2384-
Asm->GetTempSymbol("debug_loc", Offset));
2360+
Offset = DD->CopyDebugLocNoReloc(Offset);
2361+
addUInt(VariableDie, dwarf::DW_AT_location, dwarf::DW_FORM_sec_offset, Offset);
2362+
}
2363+
if (DV.getDecorations().size() > 0)
2364+
{
2365+
addString(VariableDie, dwarf::DW_AT_description, DV.getDecorations());
23852366
}
23862367
DV.setDIE(VariableDie);
23872368
return VariableDie;
@@ -2429,94 +2410,27 @@ void CompileUnit::buildLocation(const llvm::Instruction* pDbgInst, DbgVariable&
24292410
return;
24302411
}
24312412

2432-
bool addDecoration = false;
2433-
if (VISAModule->isDirectElfInput)
2413+
if (FirstLoc.HasSurface())
24342414
{
2435-
if (FirstLoc.HasSurface())
2436-
{
2437-
IGC::DIEBlock* Block = new (DIEValueAllocator)IGC::DIEBlock();
2438-
addRegisterOp(Block, FirstLoc.GetSurface());
2439-
// Now attach the surface information to the DIE.
2440-
addBlock(VariableDie, dwarf::DW_AT_segment, Block);
2441-
}
2442-
2443-
IGC::DIEBlock* locationAT = nullptr;
2444-
if (FirstLoc.IsSLM())
2445-
locationAT = buildSLM(DV, &FirstLoc);
2446-
else if (FirstLoc.IsSampler())
2447-
locationAT = buildSampler(DV, &FirstLoc);
2448-
else if (FirstLoc.HasSurface() &&
2449-
(DV.getType() && DV.getType()->getTag() == dwarf::DW_TAG_pointer_type))
2450-
locationAT = buildPointer(DV, &FirstLoc);
2451-
else
2452-
locationAT = buildGeneral(DV, &Locs, nullptr);
2453-
2454-
if (locationAT)
2455-
addBlock(VariableDie, dwarf::DW_AT_location, locationAT);
2456-
addDecoration = true;
2415+
IGC::DIEBlock* Block = new (DIEValueAllocator)IGC::DIEBlock();
2416+
addRegisterOp(Block, FirstLoc.GetSurface());
2417+
// Now attach the surface information to the DIE.
2418+
addBlock(VariableDie, dwarf::DW_AT_segment, Block);
24572419
}
2458-
else
2459-
{
2460-
// Variable which is not immediate can have surface, location or both.
2461-
if (FirstLoc.HasSurface())
2462-
{
2463-
IGC::DIEBlock* Block = new (DIEValueAllocator)IGC::DIEBlock();
2464-
addRegisterOp(Block, FirstLoc.GetSurface());
2465-
// Now attach the surface information to the DIE.
2466-
addBlock(VariableDie, dwarf::DW_AT_segment, Block);
2467-
if (!FirstLoc.HasLocation())
2468-
{
2469-
// Make sure there is always a location attribute when there is a surface attribute.
2470-
// In this case, attach an zero address opcode location information to the DIE.
2471-
IGC::DIEBlock* nBlock = new (DIEValueAllocator)IGC::DIEBlock();
2472-
addUInt(nBlock, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
2473-
dwarf::Form form = (Asm->GetPointerSize() == 8) ? dwarf::DW_FORM_data8 : dwarf::DW_FORM_data4;
2474-
addUInt(nBlock, form, 0);
2475-
2476-
addBlock(VariableDie, dwarf::DW_AT_location, nBlock);
2477-
}
2478-
}
2479-
2480-
if (FirstLoc.HasLocation())
2481-
{
2482-
#if 0
2483-
/* This has been disabled because of following kind of metadata node generated:
2484-
!98 = metadata !{i32 786688, metadata !11, metadata !"adder", metadata !6, i32 4, metadata !14, i32 0, metadata !56, i64
2485-
2, i64 1, i64 32}
2486-
2487-
numOperands here indicates complex addressing is used. But for complex addressing,
2488-
9th operand should be a metadata node whereas here integer nodes are added.
2489-
*/
2490-
IGC_ASSERT_MESSAGE(!(DV.variableHasComplexAddress() || DV.isBlockByrefVariable()), "Should handle complex address");
2491-
#endif
2492-
IGC::DIEBlock* Block = new (DIEValueAllocator)IGC::DIEBlock();
24932420

2494-
if (!FirstLoc.IsInMemory())
2495-
{
2496-
IGC_ASSERT_MESSAGE(FirstLoc.IsRegister(), "Direct location must be register");
2497-
addRegisterOp(Block, FirstLoc.GetRegister());
2498-
}
2499-
else
2500-
{
2501-
if (FirstLoc.IsRegister())
2502-
{
2503-
addRegisterOffset(Block, FirstLoc.GetRegister(), FirstLoc.GetOffset());
2504-
}
2505-
else
2506-
{
2507-
addUInt(Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
2508-
addSInt(Block, dwarf::DW_FORM_udata, FirstLoc.GetOffset());
2509-
}
2510-
}
2511-
2512-
// Now attach the location information to the DIE.
2513-
addBlock(VariableDie, dwarf::DW_AT_location, Block);
2514-
2515-
addDecoration = true;
2516-
}
2421+
IGC::DIEBlock* locationAT = nullptr;
2422+
if (FirstLoc.IsSLM())
2423+
locationAT = buildSLM(DV, &FirstLoc);
2424+
else if (FirstLoc.IsSampler())
2425+
locationAT = buildSampler(DV, &FirstLoc);
2426+
else if (FirstLoc.HasSurface() &&
2427+
(DV.getType() && DV.getType()->getTag() == dwarf::DW_TAG_pointer_type))
2428+
locationAT = buildPointer(DV, &FirstLoc);
2429+
else
2430+
locationAT = buildGeneral(DV, &Locs, nullptr);
25172431

2518-
DV.setDIE(VariableDie);
2519-
}
2432+
if (locationAT)
2433+
addBlock(VariableDie, dwarf::DW_AT_location, locationAT);
25202434
}
25212435

25222436
IGC::DIEBlock* CompileUnit::buildPointer(DbgVariable& var, const VISAVariableLocation* loc)

0 commit comments

Comments
 (0)