Skip to content

Commit e8ecfc3

Browse files
pratikasharsys_zuul
authored andcommitted
Partial change to fix support for debug info for stack call functions. Emission of .debug_frames is pending.
Change-Id: I63d02954cb2bc50b62c84486744a6ec22642382d
1 parent 724a2a5 commit e8ecfc3

File tree

9 files changed

+269
-69
lines changed

9 files changed

+269
-69
lines changed

IGC/Compiler/CISACodeGen/DebugInfo.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,27 @@ bool DebugInfoPass::runOnModule(llvm::Module& M)
111111
m_pDebugEmitter = m_currShader->diData->m_pDebugEmitter;
112112
std::vector<std::pair<unsigned int, std::pair<llvm::Function*, IGC::VISAModule*>>> sortedVISAModules;
113113

114+
// Sort modules in order of their placement in binary
115+
DbgDecoder decodedDbg(m_currShader->ProgramOutput()->m_debugDataGenISA);
116+
auto getLastGenOff = [&decodedDbg](IGC::VISAModule* v)
117+
{
118+
unsigned int genOff = 0;
119+
120+
for (auto& item : decodedDbg.compiledObjs)
121+
{
122+
auto& name = item.kernelName;
123+
auto firstInst = (v->GetInstInfoMap()->begin())->first;
124+
auto funcName = firstInst->getParent()->getParent()->getName();
125+
if (funcName.compare(name) == 0)
126+
genOff = item.CISAIndexMap.back().second;
127+
}
128+
129+
return genOff;
130+
};
131+
114132
for (auto& m : m_currShader->diData->m_VISAModules)
115133
{
116-
auto lastVISAId = m.second->GetCurrentVISAId();
134+
auto lastVISAId = getLastGenOff(m.second);
117135
sortedVISAModules.push_back(std::make_pair(lastVISAId, std::make_pair(m.first, m.second)));
118136
}
119137

IGC/Compiler/DebugInfo/DwarfDebug.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,9 @@ void DwarfDebug::emitDebugLoc()
23342334
}
23352335
}
23362336
}
2337+
2338+
DotDebugLocEntries.clear();
2339+
23372340
#else
23382341
for (SmallVectorImpl<DotDebugLocEntry>::iterator
23392342
I = DotDebugLocEntries.begin(), E = DotDebugLocEntries.end();

IGC/Compiler/DebugInfo/DwarfDebug.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,14 @@ namespace IGC
661661
unsigned int lowPc = 0, highPc = 0;
662662

663663
DbgDecoder* getDecodedDbg() { return decodedDbg; }
664-
void setDecodedDbg(DbgDecoder* d) { decodedDbg = d; }
664+
void setDecodedDbg(DbgDecoder* d)
665+
{
666+
if (decodedDbg)
667+
{
668+
delete decodedDbg;
669+
}
670+
decodedDbg = d;
671+
}
665672
unsigned int CopyDebugLoc(unsigned int offset);
666673

667674
private:

IGC/Compiler/DebugInfo/VISADebugEmitter.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ void DebugEmitter::Finalize(void *&pBuffer, unsigned int &size, bool finalize)
215215
m_pDwarfDebug->setDecodedDbg(decodedDbg);
216216

217217
m_pVISAModule->buildDirectElfMaps();
218+
auto co = m_pVISAModule->getCompileUnit();
218219

219220
// Emit src line mapping directly instead of
220221
// relying on dbgmerge. elf generated will have
@@ -226,20 +227,30 @@ void DebugEmitter::Finalize(void *&pBuffer, unsigned int &size, bool finalize)
226227
unsigned int prevLastGenOff = lastGenOff;
227228
m_pDwarfDebug->lowPc = lastGenOff;
228229

229-
for (auto item : m_pVISAModule->GenISAToVISAIndex)
230+
if (co->subs.size() == 0)
230231
{
231-
if ((item.first > lastGenOff) || ((item.first | lastGenOff) == 0))
232+
GenISAToVISAIndex = m_pVISAModule->GenISAToVISAIndex;
233+
if(GenISAToVISAIndex.size() > 0)
234+
lastGenOff = GenISAToVISAIndex.back().first;
235+
m_pDwarfDebug->lowPc = co->relocOffset;
236+
}
237+
else
238+
{
239+
for (auto item : m_pVISAModule->GenISAToVISAIndex)
232240
{
233-
if (item.second <= subEnd ||
234-
item.second == 0xffffffff)
241+
if ((item.first > lastGenOff) || ((item.first | lastGenOff) == 0))
235242
{
236-
GenISAToVISAIndex.push_back(item);
237-
lastGenOff = item.first;
238-
continue;
239-
}
243+
if (item.second <= subEnd ||
244+
item.second == 0xffffffff)
245+
{
246+
GenISAToVISAIndex.push_back(item);
247+
lastGenOff = item.first;
248+
continue;
249+
}
240250

241-
if (item.second > subEnd)
242-
break;
251+
if (item.second > subEnd)
252+
break;
253+
}
243254
}
244255
}
245256

0 commit comments

Comments
 (0)