[LLVMdev] Runtime alignment

Nick Lewycky nlewycky at google.com
Fri Sep 26 14:58:24 PDT 2014


On 26 September 2014 14:33, DeadMG <wolfeinstein at gmail.com> wrote:

> Thanks, that's sweet. I've been thinking about using this in various
> contexts and I've come to the conclusion that it's not that useful because
> the alloca alignment cannot be a ConstantExpr, so there's no way to defer
> alignment for trying to create IR that's more target-independent. I've been
> thinking about suggesting that some IR-level constructs that currently
> require literal constants, like array sizes and alloca alignment, should be
> changed to be ConstantExprs.
>

I don't think that can work either. How do we generate code for an alloca
whose alignment is equal to "&f - &g" when we don't yet know the addresses
of 'f' or of 'g'? They may not be known until after the loader runs.

On 25 September 2014 00:33, Nick Lewycky <nlewycky at google.com> wrote:
>
>> On 24 September 2014 15:09, Mark Boyall <wolfeinstein at gmail.com> wrote:
>>
>>> For the size of a type to be calculated at runtime, there is a known
>>> trick with gep. Is there any similar trick for determining the alignment of
>>> a type at runtime for target-independent IR?
>>>
>>
>> There's ConstantExpr::getAlignOf to go with getSizeOf and getOffsetOf.
>> The implementation has this comment:
>>
>>   // alignof is implemented as: (i64) gep ({i1,Ty}*)null, 0, 1
>>   // Note that a non-inbounds gep is used, as null isn't within any object.
>>
>> Nick
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140926/e672be57/attachment.html>


More information about the llvm-dev mailing list