Skip to content

Commit 3f93625

Browse files
joaosaffranjoaosaffran-zzjoaosaffran
authored
[HLSL] Fix debug info generation for RWBuffer types (llvm#119041)
This PR fix the debug infor generation for RWBuffer types. - This implements the [same fix as DXC](microsoft/DirectXShaderCompiler#6296). - Adds the HLSLAttributedResource debug info generation Closes llvm#118523 --------- Co-authored-by: Joao Saffran <[email protected]> Co-authored-by: joaosaffran <[email protected]>
1 parent f3bc8c3 commit 3f93625

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3492,6 +3492,11 @@ llvm::DIType *CGDebugInfo::CreateType(const PipeType *Ty, llvm::DIFile *U) {
34923492
return getOrCreateType(Ty->getElementType(), U);
34933493
}
34943494

3495+
llvm::DIType *CGDebugInfo::CreateType(const HLSLAttributedResourceType *Ty,
3496+
llvm::DIFile *U) {
3497+
return getOrCreateType(Ty->getWrappedType(), U);
3498+
}
3499+
34953500
llvm::DIType *CGDebugInfo::CreateEnumType(const EnumType *Ty) {
34963501
const EnumDecl *ED = Ty->getDecl();
34973502

@@ -3834,12 +3839,13 @@ llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit) {
38343839

38353840
case Type::TemplateSpecialization:
38363841
return CreateType(cast<TemplateSpecializationType>(Ty), Unit);
3842+
case Type::HLSLAttributedResource:
3843+
return CreateType(cast<HLSLAttributedResourceType>(Ty), Unit);
38373844

38383845
case Type::CountAttributed:
38393846
case Type::Auto:
38403847
case Type::Attributed:
38413848
case Type::BTFTagAttributed:
3842-
case Type::HLSLAttributedResource:
38433849
case Type::Adjusted:
38443850
case Type::Decayed:
38453851
case Type::DeducedTemplateSpecialization:

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ class CGDebugInfo {
196196
llvm::DIType *CreateType(const PointerType *Ty, llvm::DIFile *F);
197197
llvm::DIType *CreateType(const BlockPointerType *Ty, llvm::DIFile *F);
198198
llvm::DIType *CreateType(const FunctionType *Ty, llvm::DIFile *F);
199+
llvm::DIType *CreateType(const HLSLAttributedResourceType *Ty,
200+
llvm::DIFile *F);
199201
/// Get structure or union type.
200202
llvm::DIType *CreateType(const RecordType *Tyg);
201203

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// 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
2+
3+
4+
// CHECK: [[DWTag:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "RWBuffer<float>",
5+
// CHECK: [[RWBuffer:![0-9]+]] = distinct !DISubprogram(name: "RWBuffer",
6+
// CHECK-SAME: scope: [[DWTag]]
7+
// CHECK: [[FirstThis:![0-9]+]] = !DILocalVariable(name: "this", arg: 1, scope: [[RWBuffer]], type: [[thisType:![0-9]+]]
8+
// CHECK: [[thisType]] = !DIDerivedType(tag: DW_TAG_reference_type, baseType: [[DWTag]], size: 32)
9+
RWBuffer<float> Out : register(u7, space4);
10+
11+
[numthreads(8,1,1)]
12+
void main(int GI : SV_GroupIndex) {
13+
Out[GI] = 0;
14+
}

0 commit comments

Comments
 (0)