<div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 27, 2012 at 2:16 PM, Dmitry Vyukov <span dir="ltr"><<a href="mailto:dvyukov@google.com" target="_blank" class="cremed">dvyukov@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 class="gmail_extra"><div class="im">On Thu, Jun 28, 2012 at 1:07 AM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank" class="cremed">chandlerc@google.com</a>></span> wrote:<br>
</div><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I suspect you'll need to work still harder than this... =[</blockquote><div><br></div></div><div>I know :)</div><div>Now I need to understand how exactly it is broken.</div></div></div></blockquote><div><br></div><div>
Hmm, I may also need to better understand what you're attempting to achieve with this patch (based on Timur's comment).</div><div><br></div><div>You define memset, memcpy, etc in a header file -- what callers use them? Most callers moved to 'internal_foo' versions.</div>
<div><br></div><div>To answer Timur's question -- yes its ok, but it's hard to control which (instrumented or not-instrumented) gets used if they are inserted by LLVM, and thus have the normal names. It occurs to me that my post-process name-mangling tool would solve this problem as well...</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><div class="gmail_quote"><div class="im"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>You'll need to compile with -fno-builtins in order to prevent LLVM's optimizer from recognizing your code as equivalent to 'memset' or 'memcpy', and replacing it with a call to those functions. =/</div>

</blockquote><div><br></div></div><div>I believe we are compiling with -fno-builtin.</div><div>You mentioned that I also need <span style="font-family:arial,sans-serif;font-size:12.800000190734863px">-ffreestanding:</span></div>
</div></div></blockquote><div><br></div><div>Yea, -ffreestanding may be better. It is a superset of -fno-builtin</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_extra"><div class="gmail_quote">
<div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">"Yes, there are attributes which can be attached to the non-instrumented memcpy function, provided by the runtime and selected due to -ffreestanding, which will force inlining. __attribute__((always_inline))</span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">, __attribute__((flatten))"</span><br>
</div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Why do I need it?</span></div></div></div>
</blockquote><div><br></div><div>Need which?</div><div><br></div><div>You need '-ffreestanding' so that your source code can implement 'memset' itself, and that implementation will be used rather than assuming that at some point 'libc' will get linked in and we can call *its* memset. This is necessary even if your function isn't named 'memset' but something eles.</div>
<div><br></div><div>The __attribute__((always_inline)) is needed if you want to force this function to be inlined into its callers. I don't recall off hand why this was important?</div></div></div>