<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 28, 2016 at 9:37 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.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 dir="ltr"><br><br><div class="gmail_quote"><span class="gmail-"><div dir="ltr">On Sat, Nov 26, 2016 at 11:31 PM Sean Silva via Phabricator via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@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">silvas created this revision.<br class="gmail-m_-5286691130658969282gmail_msg">
silvas added reviewers: ruiu, rafael.<br class="gmail-m_-5286691130658969282gmail_msg">
silvas added a subscriber: llvm-commits.<br class="gmail-m_-5286691130658969282gmail_msg">
silvas set the repository for this revision to rL LLVM.<br class="gmail-m_-5286691130658969282gmail_msg">
<br class="gmail-m_-5286691130658969282gmail_msg">
This function is incredibly hot (it is called unconditionally for every relocation) and so we need everything the compiler can give us for it. It is just a helper anyway.<br class="gmail-m_-5286691130658969282gmail_msg">
<br class="gmail-m_-5286691130658969282gmail_msg">
This change is good for 3-4% speedup on clang-fsds with `ld.lld -O1`.<br class="gmail-m_-5286691130658969282gmail_msg">
<br class="gmail-m_-5286691130658969282gmail_msg">
The compiler that needed this identifies itself as `gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609`<br class="gmail-m_-5286691130658969282gmail_msg"></blockquote><div><br></div></span><div>Is it important to optmize our code for this compiler? My general understanding was that we mostly focus on selfhost perf for LLVM projects - correctness everywhere, then just bootstrap to get good perf. That way we can just fix compiler bugs in the compiler rather than both in the compiler and in the project source.</div></div></div></blockquote><div><br></div><div>This is a fine idea in theory, but in practice we don't want LLD too sensitive to choice of compiler. We don't want to have to qualify LLD's performance claims with a huge list of fine print about how you need to build it. For example, a Debian or Gentoo packager or the build of LLD for the FreeBSD base system is unlikely to be willing to do a PGO build, nor will they necessarily be willing to compile LLD with the compiler (or compiler version) of our choice. Our users should not suffer for this if we can avoid it pretty easily.</div><div><br></div><div>LLD is very different from Clang or LLVM -- both Clang and LLVM are very large (at least an order of magnitude or two larger than LLD could ever become) and have a pretty flat profile: there is a real software engineering maintainability question about whether it is worth it to annotate for the compiler, because you would have to annotate so many places in order to get any significant gain. PGO is a good fit for that, since it avoids the software engineering issues by letting the compiler iterate over the entire program and get lots of tiny gains. However, for LLD it is different; LLD is a much smaller codebase and spends almost all of its time in just a handful of functions (this is slight hyperbole, but the profile is very concentrated and not flat at all). So a very small and manageable set of targeted fixes can help a lot.</div><div><br></div><div>E.g. Rui's <a href="https://reviews.llvm.org/D27155">https://reviews.llvm.org/D27155</a> improves a key performance metric (building a single debug binary on an otherwise unloaded machine) by 25% by swapping out a single isolated subroutine with a faster implementation.</div><div><br></div><div>-- Sean Silva</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 dir="ltr"><div class="gmail_quote"><span class="gmail-"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Also, this will allow us in the future to more accurately assess the benefits of PGO for building LLD. If we can get this speedup easily without PGO by just applying an attribute, we don't want this 3-4% to inflate the benefit of PGO when we try PGO.<br class="gmail-m_-5286691130658969282gmail_msg"></blockquote><div><br></div></span><div>I'm not sure that's necessarily an inflation (though if LLVM is missing this inline opportunity that it should be getting even without PGO, etc - then we should fix LLVM) - I think PGO should help LLVM get situations like this that a user /could/ fix, but finding and fixing them all is expensive/not practical overall, so having a tool that can get them for you is valuable.<br><br>- Dave</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"><span class="gmail-">
<br class="gmail-m_-5286691130658969282gmail_msg">
<br class="gmail-m_-5286691130658969282gmail_msg">
Repository:<br class="gmail-m_-5286691130658969282gmail_msg">
  rL LLVM<br class="gmail-m_-5286691130658969282gmail_msg">
<br class="gmail-m_-5286691130658969282gmail_msg">
<a href="https://reviews.llvm.org/D27147" rel="noreferrer" class="gmail-m_-5286691130658969282gmail_msg" target="_blank">https://reviews.llvm.org/<wbr>D27147</a><br class="gmail-m_-5286691130658969282gmail_msg">
<br class="gmail-m_-5286691130658969282gmail_msg">
Files:<br class="gmail-m_-5286691130658969282gmail_msg">
  ELF/Relocations.cpp<br class="gmail-m_-5286691130658969282gmail_msg">
<br class="gmail-m_-5286691130658969282gmail_msg">
<br class="gmail-m_-5286691130658969282gmail_msg">
Index: ELF/Relocations.cpp<br class="gmail-m_-5286691130658969282gmail_msg">
==============================<wbr>==============================<wbr>=======<br class="gmail-m_-5286691130658969282gmail_msg">
--- ELF/Relocations.cpp<br class="gmail-m_-5286691130658969282gmail_msg">
+++ ELF/Relocations.cpp<br class="gmail-m_-5286691130658969282gmail_msg">
@@ -421,10 +421,10 @@<br class="gmail-m_-5286691130658969282gmail_msg">
 }<br class="gmail-m_-5286691130658969282gmail_msg">
<br class="gmail-m_-5286691130658969282gmail_msg">
 template <class ELFT><br class="gmail-m_-5286691130658969282gmail_msg">
-static RelExpr adjustExpr(const elf::ObjectFile<ELFT> &File, SymbolBody &Body,<br class="gmail-m_-5286691130658969282gmail_msg">
-                          bool IsWrite, RelExpr Expr, uint32_t Type,<br class="gmail-m_-5286691130658969282gmail_msg">
-                          const uint8_t *Data, InputSectionBase<ELFT> &S,<br class="gmail-m_-5286691130658969282gmail_msg">
-                          typename ELFT::uint RelOff) {<br class="gmail-m_-5286691130658969282gmail_msg">
+LLVM_ATTRIBUTE_ALWAYS_INLINE static inline RelExpr<br class="gmail-m_-5286691130658969282gmail_msg">
+adjustExpr(const elf::ObjectFile<ELFT> &File, SymbolBody &Body, bool IsWrite,<br class="gmail-m_-5286691130658969282gmail_msg">
+           RelExpr Expr, uint32_t Type, const uint8_t *Data,<br class="gmail-m_-5286691130658969282gmail_msg">
+           InputSectionBase<ELFT> &S, typename ELFT::uint RelOff) {<br class="gmail-m_-5286691130658969282gmail_msg">
   bool Preemptible = isPreemptible(Body, Type);<br class="gmail-m_-5286691130658969282gmail_msg">
   if (Body.isGnuIFunc()) {<br class="gmail-m_-5286691130658969282gmail_msg">
     Expr = toPlt(Expr);<br class="gmail-m_-5286691130658969282gmail_msg">
<br class="gmail-m_-5286691130658969282gmail_msg">
<br class="gmail-m_-5286691130658969282gmail_msg"></span>
______________________________<wbr>_________________<br class="gmail-m_-5286691130658969282gmail_msg">
llvm-commits mailing list<br class="gmail-m_-5286691130658969282gmail_msg">
<a href="mailto:llvm-commits@lists.llvm.org" class="gmail-m_-5286691130658969282gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a><br class="gmail-m_-5286691130658969282gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" class="gmail-m_-5286691130658969282gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br class="gmail-m_-5286691130658969282gmail_msg">
</blockquote></div></div>
</blockquote></div><br></div></div>