[LLVMdev] Runtime alignment

DeadMG wolfeinstein at gmail.com
Fri Sep 26 14:33:52 PDT 2014


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.

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/9f5ac92a/attachment.html>


More information about the llvm-dev mailing list