<div dir="ltr"><div><a href="http://llvm.org/docs/LangRef.html#linkage-types">http://llvm.org/docs/LangRef.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>