[clang] [HLSL] Set default DwarfVersion to 4 for HLSL. (PR #97854)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 5 12:49:58 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-hlsl

Author: Xiang Li (python3kgae)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/97854.diff


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/HLSL.h (+3) 
- (modified) clang/test/Driver/dxc_debug.hlsl (+2-1) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/97854


More information about the cfe-commits mailing list