<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 21, 2016, at 10:14 AM, Reid Kleckner <<a href="mailto:rnk@google.com" class="">rnk@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Sat, Nov 19, 2016 at 12:44 PM, Simone Atzeni via llvm-dev <span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thanks Mehdi.<br class="">
<br class="">
My pass clones the functions within a module in order to have the original function and an exact copy of the same function but with a different name, i.e. sum() and sum_parallel().<br class="">
After my pass I will run ThreadSanitizer instrumentation pass only on the new copy of the functions, i.e. only the “_parallel” functions will be instrumented by tsan.<br class="">
<br class="">
In some programs that I am compiling, the functions such as atoi and atof get cloned but I want to avoid this, and I noticed that only those functions have GlobalValue::<wbr class="">AvailableExternallyLinkage, so I was wondering if checking the linkage is enough to avoid those library functions or there could be situations of functions with that linkage but that have the body implemented in the same module.<br class=""></blockquote><div class=""><br class=""></div><div class="">Checking for this linkage should be enough. If a function has available_externally linkage, then some other module *must* provide an equivalent, strong definition of that function, so you shouldn't need (or want) to clone such functions.</div></div></div></div></div></blockquote><div><br class=""></div>I disagree: depending on your use case you may want to instrument all the user code of an application. Any available_externally function may be inlined in the current module, in a non-instrumented form. The fact that it will be instrumented in the original module is not enough.</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div><div> </div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">The root of your problem is that you clone "atoi" into "atoi_parallel", but you leave the linkage as available_externally, which means that you are also promising that some other module out there provides the symbol "atoi_parallel". Obviously, that isn't the case, so you get linker errors.<br class=""></div><div class=""><br class=""></div><div class=""><div class="">You could also resolve your problem by giving the parallel clones 'internal' linkage.</div></div></div></div></div>
</div></blockquote></div><br class=""></body></html>