File tree Expand file tree Collapse file tree 9 files changed +38
-17
lines changed Expand file tree Collapse file tree 9 files changed +38
-17
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,10 @@ class SpirvModule {
165
165
return debugInstructions;
166
166
}
167
167
168
+ // Access the one DebugCompilationUnit per module
169
+ SpirvDebugCompilationUnit *getDebugCompilationUnit ();
170
+ void setDebugCompilationUnit (SpirvDebugCompilationUnit *unit);
171
+
168
172
// Adds the given OpModuleProcessed to the module.
169
173
void addModuleProcessed (SpirvModuleProcessed *);
170
174
@@ -224,6 +228,10 @@ class SpirvModule {
224
228
225
229
// Keep all rich DebugInfo instructions.
226
230
llvm::SmallVector<SpirvDebugInstruction *, 32 > debugInstructions;
231
+
232
+ // There is one debugCompilationUnit per module
233
+ SpirvDebugCompilationUnit *debugCompilationUnit;
234
+
227
235
// Whether current module is in pervertex interpolation mode.
228
236
bool perVertexInterp;
229
237
};
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ SpirvDebugTypeComposite *DebugTypeVisitor::createDebugTypeComposite(
62
62
} else {
63
63
auto *dbgSrc = spvBuilder.createDebugSource (file);
64
64
setDefaultDebugInfo (dbgSrc);
65
- auto dbgCompUnit = spvBuilder.createDebugCompilationUnit (dbgSrc );
65
+ auto dbgCompUnit = spvBuilder.getModule ()-> getDebugCompilationUnit ( );
66
66
setDefaultDebugInfo (dbgCompUnit);
67
67
debugInfo =
68
68
&debugInfoMap.insert ({file, RichDebugInfo (dbgSrc, dbgCompUnit)})
Original file line number Diff line number Diff line change @@ -1214,6 +1214,7 @@ SpirvBuilder::createDebugCompilationUnit(SpirvDebugSource *source) {
1214
1214
auto *inst = new (context) SpirvDebugCompilationUnit (
1215
1215
/* version*/ 1 , /* DWARF version*/ 4 , source);
1216
1216
mod->addDebugInfo (inst);
1217
+ mod->setDebugCompilationUnit (inst);
1217
1218
return inst;
1218
1219
}
1219
1220
Original file line number Diff line number Diff line change @@ -1073,9 +1073,10 @@ SpirvEmitter::getOrCreateRichDebugInfoImpl(llvm::StringRef file) {
1073
1073
// returns {{string key, RichDebugInfo}, true /*Success*/}.
1074
1074
// debugInfo.insert().first->second is a RichDebugInfo.
1075
1075
return &debugInfo
1076
- .insert({file, RichDebugInfo(
1077
- dbgSrc, spvBuilder.createDebugCompilationUnit(
1078
- dbgSrc))})
1076
+ .insert({file,
1077
+ RichDebugInfo(
1078
+ dbgSrc,
1079
+ spvBuilder.getModule()->getDebugCompilationUnit())})
1079
1080
.first->second;
1080
1081
}
1081
1082
Original file line number Diff line number Diff line change @@ -382,5 +382,16 @@ void SpirvModule::addModuleProcessed(SpirvModuleProcessed *p) {
382
382
moduleProcesses.push_back (p);
383
383
}
384
384
385
+ SpirvDebugCompilationUnit *SpirvModule::getDebugCompilationUnit () {
386
+ SpirvDebugCompilationUnit *unit = debugCompilationUnit;
387
+ assert (unit && " null DebugCompilationUnit" );
388
+ return unit;
389
+ }
390
+
391
+ void SpirvModule::setDebugCompilationUnit (SpirvDebugCompilationUnit *unit) {
392
+ assert (unit);
393
+ debugCompilationUnit = unit;
394
+ }
395
+
385
396
} // end namespace spirv
386
397
} // end namespace clang
Original file line number Diff line number Diff line change 6
6
// CHECK: spirv.debug.opline.include-file-1.hlsli
7
7
// CHECK: spirv.debug.opline.include-file-2.hlsli
8
8
// CHECK: spirv.debug.opline.include-file-3.hlsli
9
+ // CHECK: [[main_code:%[0-9]+]] = OpString "// RUN: %dxc -T ps_6_0 -E main -fspv-debug=rich-with-source -fcgl %s -spirv | FileCheck %s
9
10
// CHECK: [[file3_code:%[0-9]+]] = OpString "int b;
10
11
// CHECK: [[file2_code:%[0-9]+]] = OpString "static int a;
11
12
// CHECK: [[file1_code:%[0-9]+]] = OpString "int function1() {
12
- // CHECK: [[main_code:%[0-9]+]] = OpString "// RUN: %dxc -T ps_6_0 -E main -fspv-debug=rich-with-source -fcgl %s -spirv | FileCheck %s
13
13
14
+
15
+ // CHECK: {{%[0-9]+}} = OpExtInst %void [[debugSet]] DebugSource {{%[0-9]+}} [[main_code]]
14
16
// CHECK: {{%[0-9]+}} = OpExtInst %void [[debugSet]] DebugSource {{%[0-9]+}} [[file3_code]]
15
17
// CHECK: {{%[0-9]+}} = OpExtInst %void [[debugSet]] DebugSource {{%[0-9]+}} [[file2_code]]
16
18
// CHECK: {{%[0-9]+}} = OpExtInst %void [[debugSet]] DebugSource {{%[0-9]+}} [[file1_code]]
17
- // CHECK: {{%[0-9]+}} = OpExtInst %void [[debugSet]] DebugSource {{%[0-9]+}} [[main_code]]
18
19
19
20
#include "spirv.debug.opline.include-file-1.hlsli"
20
21
Original file line number Diff line number Diff line change @@ -29,19 +29,18 @@ int callFunction3() {
29
29
CALL_FUNCTION_3;
30
30
}
31
31
32
+
33
+ // CHECK: [[main:%[0-9]+]] = OpExtInst %void [[set]] DebugSource
34
+ // CHECK: [[c3:%[0-9]+]] = OpExtInst %void [[set]] DebugCompilationUnit 1 4 [[main]] HLSL
35
+ // CHECK-NOT: DebugCompilationUnit
32
36
// CHECK: [[s3:%[0-9]+]] = OpExtInst %void [[set]] DebugSource
33
- // CHECK: [[c3:%[0-9]+]] = OpExtInst %void [[set]] DebugCompilationUnit 1 4 [[s3]] HLSL
34
37
// CHECK: {{%[0-9]+}} = OpExtInst %void [[set]] DebugFunction [[f3]] {{%[0-9]+}} [[s3]] 3 1 [[c3]]
35
38
36
39
// CHECK: [[s2:%[0-9]+]] = OpExtInst %void [[set]] DebugSource
37
- // CHECK: [[c2:%[0-9]+]] = OpExtInst %void [[set]] DebugCompilationUnit 1 4 [[s2]] HLSL
38
- // CHECK: {{%[0-9]+}} = OpExtInst %void [[set]] DebugFunction [[f2]] {{%[0-9]+}} [[s2]] 2 1 [[c2]]
40
+ // CHECK: {{%[0-9]+}} = OpExtInst %void [[set]] DebugFunction [[f2]] {{%[0-9]+}} [[s2]] 2 1 [[c3]]
39
41
40
42
// CHECK: [[s1:%[0-9]+]] = OpExtInst %void [[set]] DebugSource
41
- // CHECK: [[c1:%[0-9]+]] = OpExtInst %void [[set]] DebugCompilationUnit 1 4 [[s1]] HLSL
42
- // CHECK: {{%[0-9]+}} = OpExtInst %void [[set]] DebugFunction [[f1]] {{%[0-9]+}} [[s1]] 1 1 [[c1]]
43
-
44
- // CHECK: {{%[0-9]+}} = OpExtInst %void [[set]] DebugSource
43
+ // CHECK: {{%[0-9]+}} = OpExtInst %void [[set]] DebugFunction [[f1]] {{%[0-9]+}} [[s1]] 1 1 [[c3]]
45
44
46
45
void main () {
47
46
callFunction1 ();
Original file line number Diff line number Diff line change 12
12
// CHECK: OpString
13
13
// CHECK: [[file1:%[0-9]+]] = OpString
14
14
// CHECK-SAME: spirv.debug.opline.include-file-1.hlsli
15
+ // CHECK: [[src0:%[0-9]+]] = OpExtInst %void %1 DebugSource [[main]]
15
16
// CHECK: [[src3:%[0-9]+]] = OpExtInst %void %1 DebugSource [[file3]]
16
17
// CHECK: [[src2:%[0-9]+]] = OpExtInst %void %1 DebugSource [[file2]]
17
18
// CHECK: [[src1:%[0-9]+]] = OpExtInst %void %1 DebugSource [[file1]]
18
- // CHECK: [[src0:%[0-9]+]] = OpExtInst %void %1 DebugSource [[main]]
19
19
20
20
// DebugLine cannot preceed OpFunction
21
21
// CHECK: %src_main = OpFunction %void None
Original file line number Diff line number Diff line change @@ -58,9 +58,9 @@ float4 main(VertexOutput v) : SV_Position
58
58
}
59
59
)" ;
60
60
std::string spirv = compileCodeAndGetSpirvAsm (code);
61
- EXPECT_THAT (spirv, ContainsRegex (" %50 = OpString \" // RUN: %dxc -T vs_6_0 -E "
61
+ EXPECT_THAT (spirv, ContainsRegex (" %23 = OpString \" // RUN: %dxc -T vs_6_0 -E "
62
62
" main -fspv-debug=vulkan-with-source" ));
63
- EXPECT_THAT (spirv, ContainsRegex (" DebugSource %23\n " ));
64
- EXPECT_THAT (spirv, ContainsRegex (" DebugSource %5 %50 \n " ));
63
+ EXPECT_THAT (spirv, ContainsRegex (" DebugSource %5 % 23\n " ));
64
+ EXPECT_THAT (spirv, ContainsRegex (" DebugSource %28 \n " ));
65
65
}
66
66
} // namespace
You can’t perform that action at this time.
0 commit comments