[LLVMdev] Runtime alignment

Nick Lewycky nlewycky at google.com
Wed Sep 24 16:33:31 PDT 2014


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/20140924/a5ee11fd/attachment.html>


More information about the llvm-dev mailing list