Skip to content

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

@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/chcadYss3

The following shader defines and uses a function FillZero with an inout parameter to fill an array with zeros.

// compile args: -T lib_6_7 -Xclang -emit-llvm
export void FillZero(inout int v[2]) {
  v = {0,0};
}

Clang emits FillZero as a no-op function.

; Function Attrs: alwaysinline mustprogress nofree norecurse nosync nounwind willreturn memory(none)
define void @FillZero(int [2])(ptr noalias noundef readnone byval([2 x i32]) align 4 captures(none) %0) local_unnamed_addr #0 !dbg !8 {
    #dbg_declare(ptr %0, !17, !DIExpression(), !18)
  ret void, !dbg !19
}

One DML shader with this issue is Cast_float16_native_accum32_uint8_packed32_256_Strided8D.dat

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportclang:codegenIR generation bugs: mangling, exceptions, etc.miscompilation

Type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions