<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 26 September 2014 14:33, DeadMG <span dir="ltr"><<a href="mailto:wolfeinstein@gmail.com" target="_blank">wolfeinstein@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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.<br></div></blockquote><div><br></div><div>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.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><div class="gmail_quote">On 25 September 2014 00:33, Nick Lewycky <span dir="ltr"><<a href="mailto:nlewycky@google.com" target="_blank">nlewycky@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>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></span><div>There's ConstantExpr::getAlignOf to go with getSizeOf and getOffsetOf. The implementation has this comment:</div><pre style="margin-top:0px;margin-bottom:0px;padding-top:0.5em"><span 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><span><font color="#888888"><font size="3" color="#000000"><span style="line-height:16.25px"><br></span></font></font></span></span><span><font color="#888888"><span 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></font></span></pre></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>