Skip to content

[HLSL] inout on arrays of vectors is not correctly handled #148063

Open
@Icohedron

Description

@Icohedron

After fixing #147114 there are now 14 DML shaders failing to pass validation due to error Instructions should not read uninitialized value.
While this validation error was encountered and fixed before (#139011), this appears to another unique case.

Reproduction: https://godbolt.org/z/hG1bjeGjh

The following shader defines and uses a function FillZero with an inout parameter to fill an array of vectors with zeros.
Calling FillZero with foo does not correctly set foo to zeros.

// compile args: -T cs_6_7 -E CSMain -Xclang -emit-llvm
void FillZero(inout uint32_t2 v[2]) {
  v = {{0,0},{0,0}};
}
RWStructuredBuffer<uint32_t> output;
cbuffer Constants { uint32_t2 bar[2]; }
[numthreads(1, 1, 1)] void CSMain() {
  uint32_t2 foo[2];
  FillZero(foo);
  output[0] = dot(foo[0], bar[0]);
}

Clang emits FillZero as a no-op function, and the dot product has undef as its first argument in place of foo.

define hidden void @FillZero(unsigned int vector[2][2])(ptr noalias noundef readnone byval([2 x <2 x i32>]) align 8 captures(none) %0) local_unnamed_addr #0 !dbg !56 {
  ret void, !dbg !70
}

define void @CSMain() local_unnamed_addr #2 {
  ...
  %4 = tail call i32 @llvm.dx.udot.v2i32(<2 x i32> undef, <2 x i32> %3), !dbg !100
  ...
}

One DML shader with this issue is Cast_float16_native_accum32_uint8_packed32_256_Strided8D.dat

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    Planning

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions