<div dir="ltr"><div>This sounds a lot like <a href="https://bugs.llvm.org/show_bug.cgi?id=45050">https://bugs.llvm.org/show_bug.cgi?id=45050</a>. I'm glad to hear you figured out the root cause, thank you!</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 16, 2020 at 1:55 PM Min-Yih Hsu via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">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 style="overflow-wrap: break-word;">Hi All,<div><br></div><div>Recently we discovered a (hidden) performance bug that happened when you’re using Full LTO setup + BFD linker to compile first-stage PGO executables that were expected to generate IR level profile files. That is, compiling an executable using following commands:</div><div>```</div><div><span id="gmail-m_-3301276180455801308docs-internal-guid-f9f404e4-7fff-965f-b7be-db6283532868"><span style="font-size:12pt;font-family:"Courier New";color:rgb(0,0,0);font-variant-ligatures:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">clang -flto -fprofile-generate -c sample.c -o sample.c.bc.o</span></span></div><div><span id="gmail-m_-3301276180455801308docs-internal-guid-25b12471-7fff-b740-bb93-56de3e65db05"><span style="font-size:12pt;font-family:"Courier New";color:rgb(0,0,0);font-variant-ligatures:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">clang -flto sample.c.bc.o -o sample_exe -fprofile-generate</span></span></div><div>```</div><div>The resulting sample_exe executable will <i>always</i> emit Frontend level profile files despite the presence of the -fprofile-generate flag, which should make the executable generate IR level profile files. Other prerequisites to reproduce this problem including:</div><div><div><span style="white-space:pre-wrap"> </span>• Using (latest version of) BFD linker<br></div><div><span style="white-space:pre-wrap"> </span>• Using LLVM’s own LTO linker plugin (i.e. LLVMgold.so)<br></div><div><span style="white-space:pre-wrap"> </span>• Using LLVM’s compiler-rt as the runtime library<br></div><div><span style="white-space:pre-wrap"> </span>• On a Linux / BSD platform</div></div><div>This problem has been confirmed <i>not</i> to happen with gold and LLD linkers. Impacts on usages on Windows platform remain unknown.</div><div><br></div><div>I just cooked a patch for this bug: <a href="https://reviews.llvm.org/D83967" target="_blank">https://reviews.llvm.org/D83967</a></div><div>Basically the solution (and the root cause) is similar to this patch several years ago: <a href="https://reviews.llvm.org/D34797" target="_blank">https://reviews.llvm.org/D34797</a></div><div><br></div><div>The intriguing (or annoying) part of this bug is that you’ll never find the issue (since it neither crashes nor causes significant performance regression) unless you take a look into the generated profile files. So I just want to put a heads up here, though I know most of the folks here are moving away from using BFD linkers.</div><div><br></div><div>Best,</div><div>-Min</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>