Revert "[HLSL][SPIRV] Add support for -g to generate NonSemantic Debug Info" (#188771)

Reverts llvm/llvm-project#187051

Breaks some OpenMP offload tests
This commit is contained in:
Nick Sarnie 2026-03-27 03:58:47 +09:00 committed by GitHub
parent aa2c7f136a
commit 09951fd475
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 15 additions and 90 deletions

View File

@ -694,9 +694,7 @@ static llvm::dwarf::SourceLanguage GetSourceLanguage(const CodeGenModule &CGM) {
llvm::dwarf::SourceLanguage LangTag;
if (LO.CPlusPlus) {
if (LO.HLSL)
LangTag = llvm::dwarf::DW_LANG_HLSL;
else if (LO.HIP)
if (LO.HIP)
LangTag = llvm::dwarf::DW_LANG_HIP;
else if (LO.ObjC)
LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
@ -734,9 +732,7 @@ GetDISourceLanguageName(const CodeGenModule &CGM) {
uint32_t LangVersion = 0;
llvm::dwarf::SourceLanguageName LangTag;
if (LO.CPlusPlus) {
if (LO.HLSL) {
LangTag = llvm::dwarf::DW_LNAME_HLSL;
} else if (LO.HIP) {
if (LO.HIP) {
LangTag = llvm::dwarf::DW_LNAME_HIP;
} else if (LO.ObjC) {
LangTag = llvm::dwarf::DW_LNAME_ObjC_plus_plus;

View File

@ -1,34 +0,0 @@
// Verify that HLSL shaders are tagged with DW_LANG_HLSL in the debug compile
// unit. For DWARFv6, verify the sourceLanguageName field uses DW_LNAME_HLSL.
// DXIL target, DWARFv4
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -emit-llvm \
// RUN: -disable-llvm-passes -hlsl-entry main \
// RUN: -debug-info-kind=standalone -dwarf-version=4 -o - %s \
// RUN: | FileCheck %s --check-prefix=CHECK-V4
// SPIR-V target, DWARFv4
// RUN: %clang_cc1 -triple spirv-unknown-vulkan-compute -x hlsl -emit-llvm \
// RUN: -disable-llvm-passes -hlsl-entry main \
// RUN: -debug-info-kind=standalone -dwarf-version=4 -o - %s \
// RUN: | FileCheck %s --check-prefix=CHECK-V4
// DXIL target, DWARFv6
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -emit-llvm \
// RUN: -disable-llvm-passes -hlsl-entry main \
// RUN: -debug-info-kind=standalone -dwarf-version=6 -o - %s \
// RUN: | FileCheck %s --check-prefix=CHECK-V6
// SPIR-V target, DWARFv6
// RUN: %clang_cc1 -triple spirv-unknown-vulkan-compute -x hlsl -emit-llvm \
// RUN: -disable-llvm-passes -hlsl-entry main \
// RUN: -debug-info-kind=standalone -dwarf-version=6 -o - %s \
// RUN: | FileCheck %s --check-prefix=CHECK-V6
// CHECK-V4: !DICompileUnit(language: DW_LANG_HLSL,
// CHECK-V4-NOT: !DICompileUnit(language: DW_LANG_C_plus_plus
// CHECK-V6: !DICompileUnit(sourceLanguageName: DW_LNAME_HLSL,
// CHECK-V6-NOT: !DICompileUnit(sourceLanguageName: DW_LNAME_C_plus_plus
[numthreads(1, 1, 1)] void main() {}

View File

@ -33,11 +33,9 @@ Static Compiler Commands
Command: `llc -O1 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_ALTERA_arbitrary_precision_integers input.ll -o output.spvt`
Description: Compiles an LLVM IL file to SPIR-V with (`-O1`) optimizations, targeting a 64-bit architecture. It enables the SPV_ALTERA_arbitrary_precision_integers extension.
3. **Compilation with NonSemantic.Shader.DebugInfo support**
Command: `llc -g --spirv-ext=+SPV_KHR_non_semantic_info input.ll -o output.spvt`
Description: Compiles an LLVM IL file to SPIR-V with NonSemantic.Shader.DebugInfo.100 instructions. The ``-g`` flag causes the backend to emit NSDI instructions when the module contains debug metadata. The required SPV_KHR_non_semantic_info extension must be enabled explicitly.
Note: ``--spv-emit-nonsemantic-debug-info`` is a deprecated synonym for ``-g`` and will be removed in a future release.
3. **Compilation with experimental NonSemantic.Shader.DebugInfo.100 support**
Command: `llc --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info input.ll -o output.spvt`
Description: Compiles an LLVM IL file to SPIR-V with additional NonSemantic.Shader.DebugInfo.100 instructions. It enables the required SPV_KHR_non_semantic_info extension.
4. **SPIR-V Binary Generation**
Command: `llc -O0 -mtriple=spirv64-unknown-unknown -filetype=obj input.ll -o output.spvt`

View File

@ -261,15 +261,14 @@ bool SPIRVPassConfig::addRegBankSelect() {
static cl::opt<bool> SPVEnableNonSemanticDI(
"spv-emit-nonsemantic-debug-info",
cl::desc("Deprecated. Use -g to emit SPIR-V NonSemantic.Shader.DebugInfo "
"instructions"),
cl::desc("Emit SPIR-V NonSemantic.Shader.DebugInfo.100 instructions"),
cl::Optional, cl::init(false));
void SPIRVPassConfig::addPreEmitPass() {
// The SPIRVEmitNonSemanticDI pass self-activates when the module contains
// debug info (llvm.dbg.cu). --spv-emit-nonsemantic-debug-info is a
// deprecated synonym for -g.
addPass(createSPIRVEmitNonSemanticDIPass(&getTM<SPIRVTargetMachine>()));
if (SPVEnableNonSemanticDI ||
getSPIRVTargetMachine().getTargetTriple().getVendor() == Triple::AMD) {
addPass(createSPIRVEmitNonSemanticDIPass(&getTM<SPIRVTargetMachine>()));
}
}
namespace {

View File

@ -30,8 +30,8 @@
; CHECK-SPIRV: [[debug_source_cpp:%[0-9]+]] = OpExtInst [[type_void]] [[ext_inst_non_semantic]] DebugSource [[filename_str_cpp]]
; CHECK-SPIRV: OpExtInst [[type_void]] [[ext_inst_non_semantic]] DebugCompilationUnit [[debug_info_version]] [[dwarf_version]] [[debug_source_cpp]] [[source_language_cpp]]
; CHECK-OPTION: OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
; CHECK-OPTION: OpString "/AAAAAAAAAA/BBBBBBBB/CCCCCCCCC{{[/\\]}}example.c"
; CHECK-OPTION-NOT: OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
; CHECK-OPTION-NOT: OpString "/AAAAAAAAAA/BBBBBBBB/CCCCCCCCC{{[/\\]}}example.c"
define spir_func void @foo() {
entry:

View File

@ -82,7 +82,7 @@
; CHECK-SPIRV-DAG: OpExtInst [[type_void]] [[ext_inst_non_semantic]] DebugTypeBasic [[str_float]] [[size_32bit]] [[encoding_float]] [[flag_zero]]
; CHECK-SPIRV-DAG: OpExtInst [[type_void]] [[ext_inst_non_semantic]] DebugTypeBasic [[str_double]] [[size_64bit]] [[encoding_float]] [[flag_zero]]
; CHECK-OPTION: DebugTypeBasic
; CHECK-OPTION-NOT: DebugTypeBasic
define spir_func void @test1() !dbg !9 {
entry:

View File

@ -81,7 +81,7 @@
; CHECK-SPIRV-DAG: [[debug_info_none:%[0-9]+]] = OpExtInst {{%[0-9]+ %[0-9]+}} DebugInfoNone
; CHECK-SPIRV-DAG: OpExtInst {{%[0-9]+ %[0-9]+}} DebugTypePointer [[debug_info_none]] [[i32_5]] [[i32_0]]
; CHECK-OPTION: DebugTypePointer
; CHECK-OPTION-NOT: DebugTypePointer
@gi0 = dso_local addrspace(1) global ptr addrspace(4) null, align 4, !dbg !0
@gv0 = dso_local addrspace(1) global ptr addrspace(4) null, align 4, !dbg !5

View File

@ -1,32 +0,0 @@
; Verify that the NSDI pass activates automatically when the module contains
; debug info (llvm.dbg.cu) without requiring --spv-emit-nonsemantic-debug-info.
; The language constant in DebugCompilationUnit must be 5 (HLSL).
; RUN: llc --verify-machineinstrs --spirv-ext=+SPV_KHR_non_semantic_info \
; RUN: -O0 -mtriple=spirv64-unknown-unknown %s -o - \
; RUN: | FileCheck %s
; RUN: %if spirv-tools %{ llc --verify-machineinstrs \
; RUN: --spirv-ext=+SPV_KHR_non_semantic_info \
; RUN: -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj \
; RUN: | spirv-val %}
; CHECK: OpExtension "SPV_KHR_non_semantic_info"
; CHECK: [[ext_inst:%[0-9]+]] = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
; CHECK-DAG: [[type_void:%[0-9]+]] = OpTypeVoid
; CHECK-DAG: [[type_i32:%[0-9]+]] = OpTypeInt 32 0
; CHECK-DAG: [[lang_hlsl:%[0-9]+]] = OpConstant [[type_i32]] 5
; CHECK: OpExtInst [[type_void]] [[ext_inst]] DebugCompilationUnit
; CHECK-SAME: [[lang_hlsl]]
define spir_func void @main() {
entry:
ret void
}
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3}
!0 = distinct !DICompileUnit(language: DW_LANG_HLSL, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "shader.hlsl", directory: "/src")
!2 = !{i32 7, !"Dwarf Version", i32 5}
!3 = !{i32 2, !"Debug Info Version", i32 3}

View File

@ -1,4 +1,4 @@
; RUN: not llc -O0 -mtriple=spirv-vulkan-compute --spirv-ext=+SPV_KHR_non_semantic_info %s -o /dev/null 2>&1 | FileCheck %s
; RUN: not llc -O0 -mtriple=spirv-vulkan-compute %s -o /dev/null 2>&1 | FileCheck %s
; CHECK: error: SampleErrorsDebug.ll:24:10: Non-constant offsets are not supported in sample instructions.

View File

@ -78,7 +78,6 @@
; SPIRV-O0-NEXT: Analyze Machine Code For Garbage Collection
; SPIRV-O0-NEXT: Insert fentry calls
; SPIRV-O0-NEXT: Insert XRay ops
; SPIRV-O0-NEXT: SPIRV NonSemantic.Shader.DebugInfo.100 emitter
; SPIRV-O0-NEXT: Machine Sanitizer Binary Metadata
; SPIRV-O0-NEXT: Lazy Machine Block Frequency Analysis
; SPIRV-O0-NEXT: Machine Optimization Remark Emitter
@ -218,7 +217,6 @@
; SPIRV-Opt-NEXT: Analyze Machine Code For Garbage Collection
; SPIRV-Opt-NEXT: Insert fentry calls
; SPIRV-Opt-NEXT: Insert XRay ops
; SPIRV-Opt-NEXT: SPIRV NonSemantic.Shader.DebugInfo.100 emitter
; SPIRV-Opt-NEXT: Machine Sanitizer Binary Metadata
; SPIRV-Opt-NEXT: Lazy Machine Block Frequency Analysis
; SPIRV-Opt-NEXT: Machine Optimization Remark Emitter