Skip to content

Commit d498f48

Browse files
authored
Don't preserve debug metadata with --spirv-preserve-auxdata (#2102)
It's duplicating existing information in the SPIR-V and it has complex structure. Signed-off-by: Sarnie, Nick <[email protected]>
1 parent c7a0b9b commit d498f48

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,11 +1091,12 @@ void LLVMToSPIRVBase::transAuxDataInst(SPIRVFunction *BF, Function *F) {
10911091
for (const auto &MD : AllMD) {
10921092
std::string MDName = MDNames[MD.first].str();
10931093

1094-
// spirv.Decorations and spirv.ParameterDecorations are handled
1095-
// elsewhere for both forward and reverse translation and are complicated
1096-
// to support here, so just skip them.
1094+
// spirv.Decorations, spirv.ParameterDecorations and debug information are
1095+
// handled elsewhere for both forward and reverse translation and are
1096+
// complicated to support here, so just skip them.
10971097
if (MDName == SPIRV_MD_DECORATIONS ||
1098-
MDName == SPIRV_MD_PARAMETER_DECORATIONS)
1098+
MDName == SPIRV_MD_PARAMETER_DECORATIONS ||
1099+
MD.first == LLVMContext::MD_dbg)
10991100
continue;
11001101

11011102
// Format for metadata is:
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; RUN: llvm-as < %s -o %t.bc
2+
; RUN: llvm-spirv %t.bc -spirv-text --spirv-preserve-auxdata -o - | FileCheck %s --check-prefix=CHECK-SPIRV
3+
4+
; CHECK-SPIRV: Capability
5+
; CHECK-SPIRV-NOT: NonSemanticAuxData
6+
; CHECK-SPIRV: FunctionEnd
7+
target triple = "spir64-unknown-unknown"
8+
9+
define spir_func void @foo() #1 !dbg !4 {
10+
ret void
11+
}
12+
13+
!llvm.dbg.cu = !{!0}
14+
!llvm.module.flags = !{!3}
15+
16+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang 16.0.0", isOptimized: false, emissionKind: FullDebug, enums: !2)
17+
!1 = !DIFile(filename: "foo.c", directory: "./")
18+
!2 = !{}
19+
!3 = !{i32 2, !"Debug Info Version", i32 3}
20+
!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, retainedNodes: !5)
21+
!5 = !{!9}
22+
!6 = !DISubroutineType(types: !7)
23+
!7 = !{!8, !8, !8}
24+
!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
25+
!9 = !DILabel(scope: !4, name: "top", file: !1, line: 4)
26+
!10 = !DILocation(line: 4, column: 1, scope: !4)
27+
!11 = !DILabel(scope: !4, name: "done", file: !1, line: 7)
28+
!12 = !DILocation(line: 7, column: 1, scope: !4)

0 commit comments

Comments
 (0)