<div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote">On Tue, Oct 24, 2017 at 9:27 PM, Vedant Kumar <span dir="ltr"><<a href="mailto:vsk@apple.com" target="_blank">vsk@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><span class="gmail-"><blockquote type="cite">Unreferenced linkonce globals are allowed to be discarded.</blockquote><div><br></div></span><div>Is __udivmodti4 referenced?</div></div></blockquote><div><br></div><div><br></div><div>It's referenced by a different .o file, but nothing within the module.</div><div><br></div><div>My confusion comes from the missing direct object in the sentence. Referenced by a function local to the module? Referenced by any object in the linker job?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><span class="gmail-HOEnZb"><font color="#888888"><div><br></div><div>vedant</div></font></span><div><br><div><blockquote type="cite"><div><div class="gmail-h5"><div>On Oct 24, 2017, at 6:09 PM, Andrew Kelley via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="gmail-m_-1380210676039972302Apple-interchange-newline"></div></div><div><div><div class="gmail-h5"><div dir="ltr"><div><a href="http://llvm.org/docs/LangRef.html#linkage-types" target="_blank">http://llvm.org/docs/LangRef.<wbr>html#linkage-types</a> says:</div><div><br></div><div><div>Globals with “linkonce” linkage are merged with other globals of the same name when linkage occurs. This can be used to implement some forms of inline functions, templates, or other code which must be generated in each translation unit that uses it, but where the body may be overridden with a more definitive definition later. Unreferenced linkonce globals are allowed to be discarded. Note that linkonce linkage does not actually allow the optimizer to inline the body of this function into callers because it doesn’t know if this definition of the function is the definitive definition within the program or whether it will be overridden by a stronger definition. To enable inlining and other optimizations, use “linkonce_odr” linkage.</div></div><div><br></div><div>This makes me think that linkonce globals will not be optimized out of an .o file, but they can be deleted by the linker. Here's some IR I have:</div><div><br></div><div>define linkonce i128 @__udivmodti4(i128, i128, i128*) local_unnamed_addr #0 !dbg !264 {</div><div>....</div><div>}</div><div><br></div><div>When I run:<br><br></div><div>opt -O3 -S compiler_rt.ll<br></div><div><br></div><div>It deletes the function. Is this expected behavior?</div><div><br></div><div>Is there a linkage type that lets the linker merge functions of the same name but does not let the optimizer delete the function?</div><div><br></div><div>(let me know if providing the entire .ll file would be helpful)</div><div><br></div><div>Regards,</div><div>Andrew Kelley</div></div></div></div><span class="gmail-">
______________________________<wbr>_________________<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="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br></span></div></blockquote></div><br></div></div></blockquote></div><br></div></div></div>