Ops[DWARFVersionIdx] = M->getDwarfVersion();
Ops[SourceIdx] = getSource(CU)->getId();
- generateBuildIdentifierAndStoragePath(CU);
+ if (isNonSemanticDebugInfo())
+ generateBuildIdentifierAndStoragePath(CU);
auto DwarfLang =
static_cast<llvm::dwarf::SourceLanguage>(CU->getSourceLanguage());
BuilderMap[DebugInst->getId()] = std::make_unique<DIBuilder>(*M);
- if (DebugInst->getExtSetKind() == SPIRVEIS_NonSemantic_Shader_DebugInfo_100) {
- return BuilderMap[DebugInst->getId()]->createCompileUnit(
- SourceLang, getFile(Ops[SourceIdx]), CompilerVersion, false, Flags, 0);
- }
- if (DebugInst->getExtSetKind() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200) {
- StringRef Producer = getString(Ops[ProducerIdx]);
- return BuilderMap[DebugInst->getId()]->createCompileUnit(
- SourceLang, getFile(Ops[SourceIdx]), Producer, false, Flags, 0);
- }
- // TODO: Remove this workaround once we switch to NonSemantic.Shader.* debug
- // info by default
- auto Producer = findModuleProducer();
assert(BuilderMap.size() != 0 && "No debug compile units");
- if (BuilderMap.size()==1)
+ if (isNonSemanticDebugInfo(DebugInst->getExtSetKind())) {
// Only initialize once
- setBuildIdentifierAndStoragePath();
+ if (BuilderMap.size() == 1)
+ setBuildIdentifierAndStoragePath();
+
+ // This assertion is a guard/reminder to update the Producer argument to
+ // createCompileUnit() if a new DebugInfo type is ever created
+ assert(DebugInst->getExtSetKind() ==
+ SPIRVEIS_NonSemantic_Shader_DebugInfo_100 ||
+ DebugInst->getExtSetKind() ==
+ SPIRVEIS_NonSemantic_Shader_DebugInfo_200);
- if (!StoragePath.empty()) {
return BuilderMap[DebugInst->getId()]->createCompileUnit(
- SourceLang, getFile(Ops[SourceIdx]), Producer, false, "", 0,
- StoragePath, DICompileUnit::DebugEmissionKind::FullDebug,
- BuildIdentifier);
+ SourceLang, getFile(Ops[SourceIdx]),
+ DebugInst->getExtSetKind() == SPIRVEIS_NonSemantic_Shader_DebugInfo_100
+ ? CompilerVersion
+ : getString(Ops[ProducerIdx]),
+ false, Flags, 0, StoragePath,
+ DICompileUnit::DebugEmissionKind::FullDebug, BuildIdentifier);
}
+ // TODO: Remove this workaround once we switch to NonSemantic.Shader.* debug
+ // info by default
+ auto Producer = findModuleProducer();
return BuilderMap[DebugInst->getId()]->createCompileUnit(
SourceLang, getFile(Ops[SourceIdx]), Producer, false, Flags, 0);
}
; CHECK-LLVM-SAME: producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)"
; CHECK-LLVM-NOT: producer: "spirv"
; CHECK-SPIRV: ModuleProcessed "Debug info producer: clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)"
+; CHECK-SPIRV-NOT: DebugBuildIdentifier
+; CHECK-SPIRV-NOT: DebugStoragePath
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
!1 = !DIFile(filename: "<stdin>", directory: "oneAPI")
; CHECK-LLVM-100-SAME: flags: "-O2"
; CHECK-SPIRV-200: String [[#ProducerId:]] "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)"
+; CHECK-SPIRV-200: DebugBuildIdentifier [[#]] [[#]]
+; CHECK-SPIRV-200: DebugStoragePath [[#]]
; CHECK-SPIRV-200: DebugCompilationUnit [[#]] [[#]] [[#]] [[#]] [[#ProducerId]]
; CHECK-SPIRV-200: DebugEntryPoint [[#]] [[#]] [[#ProducerId]] [[#]] {{$}}
; CHECK-SPIRV-100: String [[#ProducerId:]] "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 16a50c9e642fd085e5ceb68c403b71b5b2e0607c)"
+; CHECK-SPIRV-100: DebugBuildIdentifier [[#]] [[#]]
+; CHECK-SPIRV-100: DebugStoragePath [[#]]
; CHECK-SPIRV-100-NOT: DebugCompilationUnit [[#]] [[#]] [[#]] [[#]] [[#ProducerId]] {{$}}
; CHECK-SPIRV-100: DebugEntryPoint [[#]] [[#]] [[#ProducerId]] [[#]] {{$}}
--- /dev/null
+; Test checks that dwoId and splitDebugFilename is preserved from LLVM IR to spirv
+; and spirv to LLVM IR translation.
+
+; RUN: llvm-as %s -o %t.bc
+; RUN: llvm-spirv %t.bc --spirv-debug-info-version=nonsemantic-shader-200 -spirv-text -o - | FileCheck %s --check-prefix CHECK-SPIRV
+; RUN: llvm-spirv %t.bc --spirv-debug-info-version=nonsemantic-shader-200 -o %t.spv
+; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
+; RUN: llvm-dis %t.rev.bc -o %t.rev.ll
+; RUN: FileCheck %s --input-file %t.rev.ll --check-prefix CHECK-LLVM
+
+; CHECK-SPIRV: String [[#stringA_id:]] "11111"
+; CHECK-SPIRV: String [[#stringA_sf:]] "debugA_info.dwo"
+; CHECK-SPIRV: [[#buildID_A:]] [[#]] DebugBuildIdentifier [[#stringA_id]]
+; CHECK-SPIRV: [[#storageID_A:]] [[#]] DebugStoragePath [[#stringA_sf]]
+
+; CHECK-LLVM: !DICompileUnit
+; CHECK-LLVM-SAME: splitDebugFilename: "debugA_info.dwo"
+; CHECK-LLVM-SAME: dwoId: 11111
+; CHECK-LLVM: !DICompileUnit
+; CHECK-LLVM-SAME: splitDebugFilename: "debugA_info.dwo"
+; CHECK-LLVM-SAME: dwoId: 11111
+
+!llvm.dbg.cu = !{!7, !0}
+!llvm.module.flags = !{!3, !4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Clang", isOptimized: false, runtimeVersion: 2, splitDebugFilename: "debugA_info.dwo", emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2, dwoId: 11111)
+!1 = !DIFile(filename: "<stdin>", directory: "/")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{!6}
+!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!7 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Clang", isOptimized: false, runtimeVersion: 2, splitDebugFilename: "debugA_info.dwo", dwoId: 11111, emissionKind: FullDebug, retainedTypes: !5)
+++ /dev/null
-; Test checks that dwoId and splitDebugFilename is preserved from LLVM IR to spirv
-; and spirv to LLVM IR translation.
-
-; RUN: llvm-as %s -o %t.bc
-; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix CHECK-SPIRV
-; RUN: llvm-spirv %t.bc -o %t.spv
-; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
-; RUN: llvm-dis %t.rev.bc -o %t.rev.ll
-; RUN: FileCheck %s --input-file %t.rev.ll --check-prefix CHECK-LLVM
-
-; CHECK-SPIRV: String [[#stringA_id:]] "11111"
-; CHECK-SPIRV: String [[#stringA_sf:]] "debugA_info.dwo"
-; CHECK-SPIRV: [[#buildID_A:]] [[#]] DebugBuildIdentifier [[#stringA_id]]
-; CHECK-SPIRV: [[#storageID_A:]] [[#]] DebugStoragePath [[#stringA_sf]]
-
-; CHECK-LLVM: !DICompileUnit
-; CHECK-LLVM-SAME: splitDebugFilename: "debugA_info.dwo"
-; CHECK-LLVM-SAME: dwoId: 11111
-; CHECK-LLVM: !DICompileUnit
-; CHECK-LLVM-SAME: splitDebugFilename: "debugA_info.dwo"
-; CHECK-LLVM-SAME: dwoId: 11111
-
-!llvm.dbg.cu = !{!7, !0}
-!llvm.module.flags = !{!3, !4}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Clang", isOptimized: false, runtimeVersion: 2, splitDebugFilename: "debugA_info.dwo", emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2, dwoId: 11111)
-!1 = !DIFile(filename: "<stdin>", directory: "/")
-!2 = !{}
-!3 = !{i32 2, !"Dwarf Version", i32 4}
-!4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = !{!6}
-!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!7 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Clang", isOptimized: false, runtimeVersion: 2, splitDebugFilename: "debugA_info.dwo", dwoId: 11111, emissionKind: FullDebug, retainedTypes: !5)