<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 22, 2017 at 4:41 PM, Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">How will this interact with this trick <a href="http://llvm.org/docs/ProgrammersManual.html#tagging-considerations" target="_blank">http://llvm.org/docs/Pro<wbr>grammersManual.html#tagging-<wbr>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><br></div><div>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><div><br></div><div>User *Use::getUser() const {</div><div>  const Use *End = getImpliedUser();</div><div>  const UserRef *ref = reinterpret_cast<const UserRef *>(End);</div><div>  return ref->getInt() ? ref->getPointer()</div><div>                       : reinterpret_cast<User *>(const_cast<Use *>(End));</div><div>}</div></div><div><br></div><div>So, we were relying on vtables being two byte aligned. Now we're relying on Types being at least two byte aligned.</div><div><br></div><div>We should... clean this up at some point to operate within the language. It shouldn't be hard.</div></div></div></div>