[clang] [HLSL] Set default DwarfVersion to 4 for HLSL. (PR #97854)
Xiang Li via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 5 12:49:34 PDT 2024
https://github.com/python3kgae created https://github.com/llvm/llvm-project/pull/97854
Set default DwarfVersion to 4 for HLSL to match DXIL which does not support DwarfVersion 5.
Based on https://registry.khronos.org/SPIR-V/specs/unified1/DebugInfo.html SPIRV is currently using Dwarf4 as well.
This is for the Dwarf Version 5 part of #96912.
>From 98891ca4c962ca2acdf6878bfb2c13b3af0a3453 Mon Sep 17 00:00:00 2001
From: Xiang Li <python3kgae at outlook.com>
Date: Fri, 5 Jul 2024 15:18:10 -0400
Subject: [PATCH] [HLSL] Set default DwarfVersion to 4 for HLSL.
Set default DwarfVersion to 4 for HLSL to match DXIL which not support DwarfVersion 5.
Based on https://registry.khronos.org/SPIR-V/specs/unified1/DebugInfo.html
SPIRV is currently using Dwarf4 as well.
This is for the Dwarf Version 5 part of #96912.
---
clang/lib/Driver/ToolChains/HLSL.h | 3 +++
clang/test/Driver/dxc_debug.hlsl | 3 ++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChains/HLSL.h b/clang/lib/Driver/ToolChains/HLSL.h
index 7b775b89743188..b2a31aabab7dc1 100644
--- a/clang/lib/Driver/ToolChains/HLSL.h
+++ b/clang/lib/Driver/ToolChains/HLSL.h
@@ -52,6 +52,9 @@ class LLVM_LIBRARY_VISIBILITY HLSLToolChain : public ToolChain {
static std::optional<std::string> parseTargetProfile(StringRef TargetProfile);
bool requiresValidation(llvm::opt::DerivedArgList &Args) const;
+ // Set default DWARF version to 4 for DXIL uses version 4.
+ unsigned GetDefaultDwarfVersion() const override { return 4; }
+
private:
mutable std::unique_ptr<tools::hlsl::Validator> Validator;
};
diff --git a/clang/test/Driver/dxc_debug.hlsl b/clang/test/Driver/dxc_debug.hlsl
index 9e207da85d5de8..0eab32168982b0 100644
--- a/clang/test/Driver/dxc_debug.hlsl
+++ b/clang/test/Driver/dxc_debug.hlsl
@@ -11,4 +11,5 @@
// CHECK: "-cc1"
// CHECK-CV-SAME: -gcodeview
// CHECK-SAME: "-debug-info-kind=constructor"
-// CHECK-DWARF-SAME: -dwarf-version
+// Make sure dwarf-version is 4.
+// CHECK-DWARF-SAME: -dwarf-version=4
More information about the cfe-commits
mailing list