Skip to content

Debug info for __builtin_LinAlgMatrix has an uninitialized DWARF encoding #9183

In review

Description

With -Zi -Qembed_debug, a __builtin_LinAlgMatrix variable gets a DIBasicType with a garbage encoding that changes from run to run:

!34 = !DIBasicType(name: "__builtin_LinAlgMatrix", size: 32, align: 32, encoding: 3559765368)

Bitcode loads fine, but the text parser caps encoding at 255, so the disassembly won't reassemble. Anything that round-trips through .ll (FileCheck/opt tests, IDxcAssembler) fails with:

value for 'encoding' too large, limit is 255

The cause is in CGDebugInfo::CreateType(const BuiltinType *). It declares Encoding without initializing it, and the switch has no BuiltinType::LinAlgMatrix case. So createBasicType gets whatever was on the stack. At -Od I happened to get 0, at -O3 I get a different large number each run.

Repro:

ByteAddressBuffer Input : register(t0);
RWByteAddressBuffer Output : register(u1);

[numthreads(32, 1, 1)]
void main() {
  __builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(8, 16, 16, 2, 1)]] matrix;
  dx::__builtin_LinAlg_MatrixLoadFromDescriptor(matrix, Input, 0, 32, 0, 128);
  dx::__builtin_LinAlg_MatrixStoreToDescriptor(matrix, Output, 0, 32, 0, 128);
}
dxc -T cs_6_10 -E main -O3 -Zi -Qembed_debug -HV 2021 -enable-16bit-types repro.hlsl -Fc repro.ll
dxa repro.ll -o repro.dxo

Seen at commit 680e525, two commits before the v1.10.2611 tag. The code is unchanged on main. The public v1.10.2611 dxc.exe happened to emit no encoding (0) when I tried it, since the value is just whatever is on the stack.

Possible fix: add a LinAlgMatrix case, either as an opaque struct or a basic type with a real encoding. Also initialize Encoding so the next new builtin type doesn't hit the same bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions