[LLVMdev] Re: Re: variable sized structs in LLVM

Armin Rigo arigo at tunes.org
Wed Jun 22 08:52:41 PDT 2005


Hi Reid,

On Tue, Jun 21, 2005 at 11:15:22PM -0700, Reid Spencer wrote:
> If you believe that variable sized structs are a feature that is missing
> in LLVM, then that's another discussion. However, LLVM needs to remain
> "low level" and it is unlikely such a feature would gain much traction
> since a combination of existing features can accomplish the same thing.

The only alternative so far in our case seems to be this one (quoting
from a previous e-mail):

> 4. Implement variable sized fields as separately allocated arrays so
> that your example becomes:
>  %struct.array = type { int, int, int* }
> The third field is allocated according to the actual size needed.
> This is a bit more code generation but should be fairly efficient.

If the LLVM optimizers are clever enough to figure out that the arrays
doesn't really have to be allocated separately, but can be inlined
within the allocation of the parent structure, and moreover no pointer
indirection is needed, then it is indeed all that we need.

In this sense, the feature Carl asked for is quite low level; we are
looking for an effect that can be acheived either by optimizers working
on a higher-level description in which the optimization hint cannot be
expressed, or by giving the hint explicitely -- which so far doesn't
seem possible portably in an assembler source.


Armin




More information about the llvm-dev mailing list