<div class="gmail_quote">On 12 October 2010 05:00, Kenneth Uildriks <span dir="ltr"><<a href="mailto:kennethuil@gmail.com">kennethuil@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 class="im">On Mon, Oct 11, 2010 at 11:10 PM, John McCall <<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>> wrote:<br>
> On Oct 11, 2010, at 2:01 PM, Kenneth Uildriks wrote:<br>
>> A better way for a front-end to declare that vtbl-ptr-hacking is not<br>
>> expected and not supported is for it to emit llvm.invariant.start and<br>
>> llvm.invariant.end calls for it.<br>
><br>
> Some of us were talking about this apropos your earlier post.<br>
> @llvm.invariant.start/end aren't appropriate, because the memory *isn't*<br>
> invariant;  the user is totally allowed to destruct the object in-place and<br>
> create a new object there.  The only thing the standard tells us is that<br>
> old references and pointers are only considered to be automatically<br>
> "forwarded" to the new object (i.e. aren't just invalid) if the types match.<br>
> So we're allowed to assume that a pointer or reference validly formed<br>
> to an object of dynamic type T will always refer to an object of that<br>
> dynamic type.<br>
<br>
</div>So does that mean that we're allowed to assume that, given an "old"<br>
pointer to that memory, the vtbl-ptr slot hasn't changed?</blockquote><div><br></div><div>You're right, I hadn't thought this through. The whole point of making them local is to say that "I'm sure these callees won't modify that memory" regardless of what functions actually get called, even indirectly. We can't know that they won't modify the vptr in advance, so invariant doesn't work here. Making it non-local just means that we would need to know the static call graph, which we don't because we haven't devirtualized yet so all the calls are indirect.</div>

<div><br></div><div>Nick</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">  Which<br>
allows us to devirtualize:<br>
<br>
Base* pT = GetMyObjectThatHappensToBeT();<br>
// ...<br>
// stuff that we can't tell what it does to our memory<br>
// ...<br>
pT->A();<br>
// more mysterious stuff<br>
pT->B();<br>
// etc.<br>
<br>
as long as we can tell that a given pointer is actually pT and not<br>
another pointer copied from it or aliased to it?<br>
<div><div></div><div class="h5"><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br>