<br><br><div class="gmail_quote">On Tue, Jul 17, 2012 at 4:57 PM, Joerg Sonnenberger <span dir="ltr"><<a href="mailto:joerg@britannica.bec.de" target="_blank">joerg@britannica.bec.de</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 Tue, Jul 17, 2012 at 01:14:39PM +0400, Kostya Serebryany wrote:<br>
> On Tue, Jul 17, 2012 at 1:08 PM, Joerg Sonnenberger <<a href="mailto:joerg@britannica.bec.de">joerg@britannica.bec.de</a><br>
> > wrote:<br>
><br>
> > On Mon, Jul 16, 2012 at 05:34:56PM +0400, Kostya Serebryany wrote:<br>
> > > First Chandler's suggestion was to replace this code with<br>
> > ><br>
> > > if (*shadow1) { arg = addr1; goto report_read4; }<br>
> > > if (*shadow2) { arg = addr2; goto report_read4; }<br>
> > > if (*shadow3) { arg = addr3; goto report_read4; }<br>
> > > return;<br>
> > > report_read4:<br>
> > >   __asan_report_read4(arg);<br>
> ><br>
> > What about not using call directly for __asan_report_read4, but building<br>
> > the stack frame with explicit push + jmp? At least for x86 that is<br>
> > trivial to implement and not that much larger in terms of code.<br>
> ><br>
><br>
> Could you please explain more?<br>
> (And one thing I want to avoid is to add inline asm into the LLVM<br>
> instrumentation module)<br>
<br>
</div>The problem for __builtin_return_address is that the code merging places<br>
the wrong return address on the stack, right? </blockquote><div><br></div><div>Right. </div><div>Currently, we have unique call instruction per every instrumented memory access and thus we encode the PC in this call instruction, </div>
<div>which is never executed and resides in cold region. </div><div>If the calls get merged, the information about PC is lost and asan starts reporting errors with incorrect top frame. </div><div>If we pass PC as the second parameter to __asan_report_*, the code gets bigger and slower. </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The other potential issue<br>
is that the dead attribute might allow the compiler to skip the call in<br>
first place and implement it like a tail call. </blockquote><div><br></div><div>I don't think this may happen unless we explicitly add the tail call attribute to the call (and we don't). </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So in terms of lowering,<br>
LLVM could replace the "call __asan_report_read4" instruction with<br>
"pushq %0; jmp __asan_report_read4" or so. Alternatively, just change<br>
the ABI to not depend on __builtin_return_address sounds fine as well?<br></blockquote><div><br></div><div>How? </div><div><br></div><div>--kcc </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5"><br>
Joerg<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br>