@@ -11,6 +11,7 @@ SPDX-License-Identifier: MIT
11
11
#include " CLElfLib/ElfReader.h"
12
12
13
13
#include " DebugInfo/ScalarVISAModule.h"
14
+ #include " DebugInfo/DwarfDebug.hpp"
14
15
#include " Compiler/CISACodeGen/DebugInfo.hpp"
15
16
16
17
using namespace llvm ;
@@ -20,8 +21,6 @@ using namespace std;
20
21
// ElfReader related typedefs
21
22
using namespace CLElfLib ;
22
23
23
- void gatherDISubprogramNodes (llvm::Module& M, std::unordered_map<llvm::Function*, std::vector<llvm::DISubprogram*>>& DISubprogramNodes);
24
-
25
24
char DebugInfoPass::ID = 0 ;
26
25
char CatchAllLineNumber::ID = 0 ;
27
26
@@ -74,43 +73,7 @@ bool DebugInfoPass::runOnModule(llvm::Module& M)
74
73
if (simd32) units.push_back (simd32);
75
74
}
76
75
77
- std::unordered_map<llvm::Function*, std::vector<llvm::DISubprogram*>> DISubprogramNodes;
78
- gatherDISubprogramNodes (M, DISubprogramNodes);
79
-
80
- auto getSPDiesCollection = [&DISubprogramNodes](std::vector<llvm::Function*>& functions)
81
- {
82
- // Function argument is list of all functions for elf.
83
- // Each function may require emission of one or more DISubprogram nodes.
84
- // Return value should be a stable vector of collection of all DISubprogram nodes
85
- // but without duplicates.
86
- std::vector<llvm::DISubprogram*> retUniqueFuncVec;
87
- std::unordered_set<llvm::DISubprogram*> uniqueDISP;
88
- for (auto & f : functions)
89
- {
90
- // iterate over all DISubprogram nodes references by llvm::Function f
91
- auto & DISPNodesForF = DISubprogramNodes[f];
92
- for (auto & SP : DISPNodesForF)
93
- {
94
- if (uniqueDISP.find (SP) == uniqueDISP.end ())
95
- {
96
- retUniqueFuncVec.push_back (SP);
97
- uniqueDISP.insert (SP);
98
- }
99
- }
100
- }
101
- // This vector contains DISubprogram node pointers for which DIEs will be emitted elf
102
- // for current kernel.
103
- //
104
- // Input to IGC may have 100s of kernels. When emitting to dwarf, we can emit subprogram
105
- // DIEs defined in current kernel (+ it's recursive callees) as well as declarations of
106
- // other kernels and functions in input. These declarations quickly add up and cause
107
- // bloat of elf size without adding much benefit. This function is responsible to filter
108
- // and return only those DISubprogram nodes for which we want DIE emitted to elf. This
109
- // only includes DIEs for subprograms ever referenced in this kernel (+ it's recursive
110
- // callees). We skip emitting declaration DIEs for which no code is emitted in current
111
- // kernel.
112
- return retUniqueFuncVec;
113
- };
76
+ DwarfDISubprogramCache DISPCache;
114
77
115
78
for (auto & currShader : units)
116
79
{
@@ -242,6 +205,7 @@ bool DebugInfoPass::runOnModule(llvm::Module& M)
242
205
return p1.first < p2.first ;
243
206
});
244
207
208
+ m_pDebugEmitter->SetDISPCache (&DISPCache);
245
209
for (auto & m : sortedVISAModules)
246
210
{
247
211
m_pDebugEmitter->registerVISA (m.second .second );
@@ -250,15 +214,15 @@ bool DebugInfoPass::runOnModule(llvm::Module& M)
250
214
std::vector<llvm::Function*> functions;
251
215
std::for_each (sortedVISAModules.begin (), sortedVISAModules.end (),
252
216
[&functions](auto & item) { functions.push_back (item.second .first ); });
253
- auto SPDiesToBuild = getSPDiesCollection (functions);
217
+
254
218
for (auto & m : sortedVISAModules)
255
219
{
256
220
m_pDebugEmitter->setCurrentVISA (m.second .second );
257
221
258
222
if (--size == 0 )
259
223
finalize = true ;
260
224
261
- EmitDebugInfo (finalize, &decodedDbg, SPDiesToBuild );
225
+ EmitDebugInfo (finalize, &decodedDbg);
262
226
}
263
227
264
228
// set VISA dbg info to nullptr to indicate 1-step debug is enabled
@@ -274,13 +238,11 @@ bool DebugInfoPass::runOnModule(llvm::Module& M)
274
238
return false ;
275
239
}
276
240
277
- void DebugInfoPass::EmitDebugInfo (bool finalize, DbgDecoder* decodedDbg,
278
- const std::vector<llvm::DISubprogram*>& DISubprogramNodes)
241
+ void DebugInfoPass::EmitDebugInfo (bool finalize, DbgDecoder* decodedDbg)
279
242
{
280
243
IGC_ASSERT (m_pDebugEmitter);
281
244
282
- std::vector<char > buffer =
283
- m_pDebugEmitter->Finalize (finalize, decodedDbg, DISubprogramNodes);
245
+ std::vector<char > buffer = m_pDebugEmitter->Finalize (finalize, decodedDbg);
284
246
285
247
if (!buffer.empty ())
286
248
{
0 commit comments