<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 24 September 2014 15:09, Mark Boyall <span dir="ltr"><<a href="mailto:wolfeinstein@gmail.com" target="_blank">wolfeinstein@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div style="font-family:Calibri,sans-serif;font-size:11pt">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?</div></div></div></blockquote><div><br></div><div>There's ConstantExpr::getAlignOf to go with getSizeOf and getOffsetOf. The implementation has this comment:</div><pre id="c3" class="" style="margin-top:0px;margin-bottom:0px;padding-top:0.5em"><span class="" id="c3_1919" style="display:block">  // alignof is implemented as: (i64) gep ({i1,Ty}*)null, 0, 1<br>  // Note that a non-inbounds gep is used, as null isn't within any object.<span style="color:rgb(34,34,34);font-size:small;line-height:normal;font-family:arial"> </span><font color="#000000" size="3"><span style="line-height:16.25px"><br></span></font></span><span class="" id="c3_1919" style="display:block"><span style="color:rgb(34,34,34);font-size:small;line-height:normal;font-family:arial"><br></span></span><span style="font-family:arial;white-space:normal">Nick</span><br></pre></div></div></div>