[clang] [HLSL] support packoffset in clang codeGen (PR #91999)

Xiang Li via cfe-commits cfe-commits at lists.llvm.org
Thu May 16 15:30:03 PDT 2024


python3kgae wrote:

> > This PR will not change this. The padding will only be added when required.
> 
> _That's the problem_
> 
> > ```hlsl
> > cbuffer {
> >   float F;
> >   float2 V;
> > }
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > will still got
> > ```llvm
> > type { float, <2 x float>}
> > ```
> 
> And there will implicitly be padding between the two elements based on what data layout does because the vector will be 64-bit aligned, which _is not_ how cbuffers work.
> 
> But that's actually not the biggest problem here. The biggest problem is that we shouldn't add padding for `packoffset`, but not for things that are implicitly laid out, and we should have a plan for how we lower this before we do any of this.
> 
> Your design document that you based this off of explicitly excluded all the IR representations. We shouldn't write this code until the design doc is updated with the IR and lowering design.

This will only affect a compiler generated struct for cbuffer layout. It should not affect any other struct layout of the compiler.

https://github.com/llvm/llvm-project/pull/91999


More information about the cfe-commits mailing list