<div>Due to using PointerIntPair and PointerLikeTypeTraits we're really using bit 2 on 64-bit builds. So we're assuming vtables have 8 byte alignment</div><div><br></div><div><br><div class="gmail_quote"><div>On Wed, Mar 22, 2017 at 5:22 PM Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg">On Wed, Mar 22, 2017 at 4:41 PM, Craig Topper <span class="gmail_msg"><<a href="mailto:craig.topper@gmail.com" class="gmail_msg" target="_blank">craig.topper@gmail.com</a>></span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_msg">How will this interact with this trick <a href="http://llvm.org/docs/ProgrammersManual.html#tagging-considerations" class="gmail_msg" target="_blank">http://llvm.org/docs/ProgrammersManual.html#tagging-considerations</a> where we make an assumption that the vtable ptr lives at the start of the User object. Is the assumption now on the Type* that will now be at the start of Value?</div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div></div><div class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">Yes, I think you're right. This code here reinterprets the vptr (or Type* now) as a UserRef, checks the bottom bit, and if it is unset, reinterprets it as a User. Otherwise, it masks the bit and loads from it to get back to the User:</div><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">User *Use::getUser() const {</div><div class="gmail_msg">  const Use *End = getImpliedUser();</div><div class="gmail_msg">  const UserRef *ref = reinterpret_cast<const UserRef *>(End);</div><div class="gmail_msg">  return ref->getInt() ? ref->getPointer()</div><div class="gmail_msg">                       : reinterpret_cast<User *>(const_cast<Use *>(End));</div><div class="gmail_msg">}</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">So, we were relying on vtables being two byte aligned. Now we're relying on Types being at least two byte aligned.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">We should... clean this up at some point to operate within the language. It shouldn't be hard.</div></div></div></div>
</blockquote></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature">~Craig</div>