[llvm] [SROA][TTI][DirectX] Add support for struct alloca decomposition (PR #161601)

Deric C. via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 2 09:20:59 PDT 2025


Icohedron wrote:

> > It should be noted that struct alloca decomposition is unsafe in languages that allow dynamic indexing across struct members (e.g., treating a pointer to one member as a base for accessing others via computed offsets). Such behavior can violate the assumptions of this decomposition, which expects each member to be accessed independently and explicitly.
> > Therefore struct alloca decomposition is disabled by default and must be explicitly enabled via an SROA pass option or TargetTransformInfo via shouldDecomposeStructAllocas.
> 
> Notably, these languages also include LLVM IR. Transforms must always operate in terms of LLVM IR semantics, and cannot make use of additional guarantees that are not implied by those semantics.
> 
> I believe that to make this kind of transform we first need to implement the proposal at https://discourse.llvm.org/t/rfc-adding-instructions-to-to-carry-gep-type-traversal-information/88141, including the additional limitation on notional over-indexing I mention in my first reply. Or some other approach that provides the necessary guarantees at the IR level.

Understandable. In that case, I shall close this PR and open a new PR when there are LLVM IR semantics able to provide the guarantees needed for this transformation.

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


More information about the llvm-commits mailing list