<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jun 4, 2015 at 5:17 PM, Teresa Johnson <span dir="ltr"><<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Agreed. Although I assume you mean invoke the new pass under a<br>
ThinLTO-only option so that avail extern are not dropped in the<br>
compile pass before the LTO link?</blockquote><div><br></div><div>No, this pass would actually be an improvement to the standard -O2 pipeline. The special case is the regular LTO pass pipeline, which wants to run GlobalDCE but doesn't want to drop available_externally function definitions until after linker-stage inlining.</div><div><br></div><div>Consider this test case:</div><div><br></div><div><div><div>declare void @blah()</div><div>define i32 @main() {</div><div> call void @foo()</div><div> ret i32 0</div><div>}</div><div>define available_externally void @foo() noinline {</div><div> call void @bar()</div><div> ret void</div><div>}</div><div>define linkonce_odr void @bar() noinline {</div><div> call void @blah()</div><div> ret void</div><div>}</div></div></div><div><br></div><div>If I run opt -O2 on this and feed it to llc, it actually generates code for bar, even though there are no actual references to bar in the final code:</div><div><br></div><div><div>main: # @main</div><div> pushq %rax</div><div> callq foo</div><div> xorl %eax, %eax</div><div> popq %rdx</div><div> retq</div><div><br></div><div>bar: # @bar</div><div> jmp blah # TAILCALL</div></div><div><br></div><div>This corner case happens to come up organically with dllimported classes, which is why I happened to think of it. :) I'm happy with a flag to globaldce for LTO and the original patch, honestly.</div></div></div></div>