Skip to content

Commit 3516299

Browse files
sarnexjsji
authored andcommitted
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]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@d498f48
1 parent bd0ce29 commit 3516299

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

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

1110-
// spirv.Decorations and spirv.ParameterDecorations are handled
1111-
// elsewhere for both forward and reverse translation and are complicated
1112-
// to support here, so just skip them.
1110+
// spirv.Decorations, spirv.ParameterDecorations and debug information are
1111+
// handled elsewhere for both forward and reverse translation and are
1112+
// complicated to support here, so just skip them.
11131113
if (MDName == SPIRV_MD_DECORATIONS ||
1114-
MDName == SPIRV_MD_PARAMETER_DECORATIONS)
1114+
MDName == SPIRV_MD_PARAMETER_DECORATIONS ||
1115+
MD.first == LLVMContext::MD_dbg)
11151116
continue;
11161117

11171118
// 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)