<div dir="ltr">Hi Teresa,<br><br>Thank you for the help, adding the "used" attribute worked just fine.<br>It made me realize that the memset function is never inlined by the LTO optimization even without my implementation of the "EmitTargetCodeForMemSet" method.<br>I supposed that the passes dealing with the memset function happen too late, is that correct?<br><br>Thank you again,<br>Romaric</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 28, 2020 at 5:51 PM Teresa Johnson <<a href="mailto:tejohnson@google.com">tejohnson@google.com</a>> wrote:<br></div><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">ThinLTO's whole program analysis is driven off of the linker symbol resolution (at least in the case of lld, gold, bfd). Presumably when it gets into the ThinLTO link, the linker does not see any uses of your alternate memset and it is therefore removed as dead code. Have you tried marking it with __attribute__((used))? Another thing that might work is to mark it weak.<div><br></div><div>Teresa</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 28, 2020 at 8:26 AM Romaric Jodin via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><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">Hi everyone,<br><br>I have 2 implementations of "memset". A standard one, and another one optimized when the pointer and the size respect some specific constraints.<br>I am able to choose the proper one in the "EmitTargetCodeForMemSet" method that I implemented for my backend.<br><br>My issue is when I am compiling with the LTO optimisation, the linker tells me that the optimized memset symbol is undefined ("<i>ld.lld: error: undefined symbol: __memset_opt</i>"). I've looked into theLTO archive used and I found both memset functions.<br><br>It feels like when the compiler gets in "EmitTargetCodeForMemSet", it has already forgotten about the optimized memset function that was in the archive because it was not used initially.<br><br>Any idea why?<br><br>Thanks in advance,<br clear="all"><div>JODIN Romaric</div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"><br></td></tr></tbody></table></span></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div style="color:rgb(136,136,136)"><span style="color:rgb(0,0,0);font-size:12.8px"><b>Romaric JODIN</b></span></div><div style="color:rgb(136,136,136)"><span style="color:rgb(0,0,0);font-size:12.8px">UPMEM</span></div><div style="color:rgb(136,136,136)"><font color="#000000" size="1"><i>Software Engineer</i></font></div><div style="color:rgb(136,136,136)"><br></div><div style="color:rgb(136,136,136)"><img src="cid:ii_jm7vnlj17_165ed4ff64757184" width="50" height="50"></div></div></div>