[clang] 3f93625 - [HLSL] Fix debug info generation for RWBuffer types (#119041)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 6 11:01:52 PST 2025
Author: joaosaffran
Date: 2025-01-06T11:01:49-08:00
New Revision: 3f936251d280d039d0a227247afd6884163e8a9a
URL: https://github.com/llvm/llvm-project/commit/3f936251d280d039d0a227247afd6884163e8a9a
DIFF: https://github.com/llvm/llvm-project/commit/3f936251d280d039d0a227247afd6884163e8a9a.diff
LOG: [HLSL] Fix debug info generation for RWBuffer types (#119041)
This PR fix the debug infor generation for RWBuffer types.
- This implements the [same fix as
DXC](https://github.com/microsoft/DirectXShaderCompiler/pull/6296).
- Adds the HLSLAttributedResource debug info generation
Closes #118523
---------
Co-authored-by: Joao Saffran <jderezende at microsoft.com>
Co-authored-by: joaosaffran <joao.saffran at microsoft.com>
Added:
clang/test/CodeGenHLSL/debug/rwbuffer_debug_info.hlsl
Modified:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index f29ddece5dbc95..560d4ce293365e 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3492,6 +3492,11 @@ llvm::DIType *CGDebugInfo::CreateType(const PipeType *Ty, llvm::DIFile *U) {
return getOrCreateType(Ty->getElementType(), U);
}
+llvm::DIType *CGDebugInfo::CreateType(const HLSLAttributedResourceType *Ty,
+ llvm::DIFile *U) {
+ return getOrCreateType(Ty->getWrappedType(), U);
+}
+
llvm::DIType *CGDebugInfo::CreateEnumType(const EnumType *Ty) {
const EnumDecl *ED = Ty->getDecl();
@@ -3834,12 +3839,13 @@ llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit) {
case Type::TemplateSpecialization:
return CreateType(cast<TemplateSpecializationType>(Ty), Unit);
+ case Type::HLSLAttributedResource:
+ return CreateType(cast<HLSLAttributedResourceType>(Ty), Unit);
case Type::CountAttributed:
case Type::Auto:
case Type::Attributed:
case Type::BTFTagAttributed:
- case Type::HLSLAttributedResource:
case Type::Adjusted:
case Type::Decayed:
case Type::DeducedTemplateSpecialization:
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 3fd0237a1c61dd..38f73eca561b7e 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -196,6 +196,8 @@ class CGDebugInfo {
llvm::DIType *CreateType(const PointerType *Ty, llvm::DIFile *F);
llvm::DIType *CreateType(const BlockPointerType *Ty, llvm::DIFile *F);
llvm::DIType *CreateType(const FunctionType *Ty, llvm::DIFile *F);
+ llvm::DIType *CreateType(const HLSLAttributedResourceType *Ty,
+ llvm::DIFile *F);
/// Get structure or union type.
llvm::DIType *CreateType(const RecordType *Tyg);
diff --git a/clang/test/CodeGenHLSL/debug/rwbuffer_debug_info.hlsl b/clang/test/CodeGenHLSL/debug/rwbuffer_debug_info.hlsl
new file mode 100644
index 00000000000000..db0388e41eae98
--- /dev/null
+++ b/clang/test/CodeGenHLSL/debug/rwbuffer_debug_info.hlsl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.6-compute -x hlsl -emit-llvm -disable-llvm-passes -o - -hlsl-entry main %s -debug-info-kind=standalone -dwarf-version=4 | FileCheck %s
+
+
+// CHECK: [[DWTag:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "RWBuffer<float>",
+// CHECK: [[RWBuffer:![0-9]+]] = distinct !DISubprogram(name: "RWBuffer",
+// CHECK-SAME: scope: [[DWTag]]
+// CHECK: [[FirstThis:![0-9]+]] = !DILocalVariable(name: "this", arg: 1, scope: [[RWBuffer]], type: [[thisType:![0-9]+]]
+// CHECK: [[thisType]] = !DIDerivedType(tag: DW_TAG_reference_type, baseType: [[DWTag]], size: 32)
+RWBuffer<float> Out : register(u7, space4);
+
+[numthreads(8,1,1)]
+void main(int GI : SV_GroupIndex) {
+ Out[GI] = 0;
+}
More information about the cfe-commits
mailing list