DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
Templated structs have invalid debug info.
Description
The debug value mapping for templated structs map to the pointer of the struct, instead of the value of the struct.
Steps to Reproduce
Compile the following shader:
// /T ps_6_0 /Zi /Od
template<typename T>
struct S {
T a, b;
T Get() {
return a + b;
}
};
[RootSignature("")]
float main(float x : X, float y : Y, float z : Z, float w : W) : SV_Target {
S<float> s;
s.a = x;
s.b = y;
return s.Get();
}
Actual Behavior
You will see that the member b of variable s has the following mapping:
call void @llvm.dbg.value(metadata float %0, i64 0, metadata !53, metadata !58), !dbg !55 ; var:"this" !DIExpression(DW_OP_bit_piece, 32, 32) func:"Get"
!53 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "this", arg: 1, scope: !8, type: !54)
!54 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32, align: 32)
!9 = !DICompositeType(tag: DW_TAG_structure_type, name: "S<float>", file: !1, line: 4, size: 64, align: 32, elements: !10, templateParams: !17)
The expected behaviour should be that this variable should be a value type, like so:
call void @llvm.dbg.value(metadata float %0, i64 0, metadata !51, metadata !55), !dbg !52 ; var:"this" !DIExpression(DW_OP_bit_piece, 32, 32) func:"Get"
!51 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "this", arg: 1, scope: !8, type: !9)
!9 = !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !1, line: 11, size: 64, align: 32, elements: !10)
(This was done by compiling a non-templated version of struct S)
Environment
- DXC version: Nightly
- Host Operating System: Windows 11