Issue 179716
Summary [HLSL] Miscompile for cbuffers with structs containing only scalars after arrays.
Labels HLSL
Assignees bogner
Reporter bogner
    We currently have a fairly embarrassing miscompile for cbuffers with a scalar after an array. Consider:

Consider:
```hlsl
struct X {
  int a1;
};
struct Q {
  int xs[2];
  X y;
};
cbuffer cbq {
  Q qs[2];
};

RWStructuredBuffer<int> Out : register(u1);

[numthreads(1,1,1)]
void main() {
 Out[0] = qs[0].y.a1;
}
```

Clang is generating a load with a row index of 1:
```hlsl
  %.load1 = call %dx.types.CBufRet.i32 @dx.op.cbufferLoadLegacy.i32(i32 59, %dx.types.Handle %0, i32 1) #1, !dbg !107
```

But this should be row 2, as the struct starts on its own row.

Godbolt: https://hlsl.godbolt.org/z/169baTz7r
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to