<div dir="ltr">Thanks!<div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 20, 2017 at 5:22 PM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On the same machine gold takes about 0.7 seconds to link the kernel :-)<br>
<br>
Cheers,<br>
Rafael<br>
<div class="HOEnZb"><div class="h5"><br>
Shoaib Meenai <<a href="mailto:smeenai@fb.com">smeenai@fb.com</a>> writes:<br>
<br>
> Rui had a talk on LLD at the developer meeting, and the talk included some<br>
> link time numbers. The Linux kernel was the only instance of gold being faster<br>
> than LLD, and a lot of people (including myself) were wondering why that was<br>
> the case. This is awesome :)<br>
><br>
> On 10/20/17, 5:05 PM, "llvm-commits on behalf of Rafael Espindola via llvm-commits" <<a href="mailto:llvm-commits-bounces@lists.llvm.org">llvm-commits-bounces@lists.<wbr>llvm.org</a> on behalf of <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: rafael<br>
> Date: Fri Oct 20 17:05:01 2017<br>
> New Revision: 316251<br>
><br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D316251-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=4IyeZA5wFDIztRZwT5Ikft6eluO180gbHODF81Mf3Ug&s=nNq0DR5WWlYGE3cjull_12CMiIvQooETqug4_X5eGLk&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject-<wbr>3Frev-3D316251-26view-3Drev&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>4IyeZA5wFDIztRZwT5Ikft6eluO180<wbr>gbHODF81Mf3Ug&s=<wbr>nNq0DR5WWlYGE3cjull_<wbr>12CMiIvQooETqug4_X5eGLk&e=</a><br>
> Log:<br>
> Don't call buildSectionOrder multiple times.<br>
><br>
> This takes linking the linux kernel from 1.52s to 0.58s.<br>
><br>
> Modified:<br>
> lld/trunk/ELF/InputSection.cpp<br>
> lld/trunk/ELF/LinkerScript.cpp<br>
> lld/trunk/ELF/LinkerScript.h<br>
><br>
> Modified: lld/trunk/ELF/InputSection.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_InputSection.cpp-3Frev-3D316251-26r1-3D316250-26r2-3D316251-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=4IyeZA5wFDIztRZwT5Ikft6eluO180gbHODF81Mf3Ug&s=Behy9uothqGelaSOG4LvVOUM2TN8W9eggw9YF8Vj97o&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_ELF_InputSection.cpp-<wbr>3Frev-3D316251-26r1-3D316250-<wbr>26r2-3D316251-26view-3Ddiff&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>4IyeZA5wFDIztRZwT5Ikft6eluO180<wbr>gbHODF81Mf3Ug&s=<wbr>Behy9uothqGelaSOG4LvVOUM2TN8W9<wbr>eggw9YF8Vj97o&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/InputSection.cpp (original)<br>
> +++ lld/trunk/ELF/InputSection.cpp Fri Oct 20 17:05:01 2017<br>
> @@ -46,6 +46,10 @@ std::string lld::toString(const InputSec<br>
> }<br>
><br>
> DenseMap<SectionBase *, int> elf::buildSectionOrder() {<br>
> + DenseMap<SectionBase *, int> SectionOrder;<br>
> + if (Config->SymbolOrderingFile.<wbr>empty())<br>
> + return SectionOrder;<br>
> +<br>
> // Build a map from symbols to their priorities. Symbols that didn't<br>
> // appear in the symbol ordering file have the lowest priority 0.<br>
> // All explicitly mentioned symbols have negative (higher) priorities.<br>
> @@ -55,7 +59,6 @@ DenseMap<SectionBase *, int> elf::buildS<br>
> SymbolOrder.insert({S, Priority++});<br>
><br>
> // Build a map from sections to their priorities.<br>
> - DenseMap<SectionBase *, int> SectionOrder;<br>
> for (InputFile *File : ObjectFiles) {<br>
> for (SymbolBody *Body : File->getSymbols()) {<br>
> auto *D = dyn_cast<DefinedRegular>(Body)<wbr>;<br>
><br>
> Modified: lld/trunk/ELF/LinkerScript.cpp<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_LinkerScript.cpp-3Frev-3D316251-26r1-3D316250-26r2-3D316251-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=4IyeZA5wFDIztRZwT5Ikft6eluO180gbHODF81Mf3Ug&s=Je_3iU9P1LF12KLZrW5An0DBWzvNjnYc1jc4UWEUv0g&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_ELF_LinkerScript.cpp-<wbr>3Frev-3D316251-26r1-3D316250-<wbr>26r2-3D316251-26view-3Ddiff&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>4IyeZA5wFDIztRZwT5Ikft6eluO180<wbr>gbHODF81Mf3Ug&s=Je_<wbr>3iU9P1LF12KLZrW5An0DBWzvNjnYc1<wbr>jc4UWEUv0g&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/LinkerScript.cpp (original)<br>
> +++ lld/trunk/ELF/LinkerScript.cpp Fri Oct 20 17:05:01 2017<br>
> @@ -274,9 +274,9 @@ static void sortInputSections(<br>
><br>
> // Compute and remember which sections the InputSectionDescription matches.<br>
> std::vector<InputSection *><br>
> -LinkerScript::<wbr>computeInputSections(const InputSectionDescription *Cmd) {<br>
> +LinkerScript::<wbr>computeInputSections(const InputSectionDescription *Cmd,<br>
> + const DenseMap<SectionBase *, int> &Order) {<br>
> std::vector<InputSection *> Ret;<br>
> - DenseMap<SectionBase *, int> Order = buildSectionOrder();<br>
><br>
> // Collects all sections that satisfy constraints of Cmd.<br>
> for (const SectionPattern &Pat : Cmd->SectionPatterns) {<br>
> @@ -326,13 +326,13 @@ void LinkerScript::discard(<wbr>ArrayRef<Inpu<br>
> }<br>
> }<br>
><br>
> -std::vector<InputSection *><br>
> -LinkerScript::<wbr>createInputSectionList(<wbr>OutputSection &OutCmd) {<br>
> +std::vector<InputSection *> LinkerScript::<wbr>createInputSectionList(<br>
> + OutputSection &OutCmd, const DenseMap<SectionBase *, int> &Order) {<br>
> std::vector<InputSection *> Ret;<br>
><br>
> for (BaseCommand *Base : OutCmd.SectionCommands) {<br>
> if (auto *Cmd = dyn_cast<<wbr>InputSectionDescription>(Base)<wbr>) {<br>
> - Cmd->Sections = computeInputSections(Cmd);<br>
> + Cmd->Sections = computeInputSections(Cmd, Order);<br>
> Ret.insert(Ret.end(), Cmd->Sections.begin(), Cmd->Sections.end());<br>
> }<br>
> }<br>
> @@ -359,6 +359,7 @@ void LinkerScript::<wbr>processSectionCommand<br>
> Ctx = make_unique<AddressState>();<br>
> Ctx->OutSec = Aether;<br>
><br>
> + DenseMap<SectionBase *, int> Order = buildSectionOrder();<br>
> // Add input sections to output sections.<br>
> for (size_t I = 0; I < SectionCommands.size(); ++I) {<br>
> // Handle symbol assignments outside of any output section.<br>
> @@ -368,7 +369,7 @@ void LinkerScript::<wbr>processSectionCommand<br>
> }<br>
><br>
> if (auto *Sec = dyn_cast<OutputSection>(<wbr>SectionCommands[I])) {<br>
> - std::vector<InputSection *> V = createInputSectionList(*Sec);<br>
> + std::vector<InputSection *> V = createInputSectionList(*Sec, Order);<br>
><br>
> // The output section name `/DISCARD/' is special.<br>
> // Any input section assigned to it is discarded.<br>
><br>
> Modified: lld/trunk/ELF/LinkerScript.h<br>
> URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_LinkerScript.h-3Frev-3D316251-26r1-3D316250-26r2-3D316251-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=4IyeZA5wFDIztRZwT5Ikft6eluO180gbHODF81Mf3Ug&s=pbQ0x-JYey0QxqiIAbrRNWhQ6PJLgAuj9Mu8zFqXRco&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__llvm.<wbr>org_viewvc_llvm-2Dproject_lld_<wbr>trunk_ELF_LinkerScript.h-<wbr>3Frev-3D316251-26r1-3D316250-<wbr>26r2-3D316251-26view-3Ddiff&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>4IyeZA5wFDIztRZwT5Ikft6eluO180<wbr>gbHODF81Mf3Ug&s=pbQ0x-<wbr>JYey0QxqiIAbrRNWhQ6PJLgAuj9Mu8<wbr>zFqXRco&e=</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/LinkerScript.h (original)<br>
> +++ lld/trunk/ELF/LinkerScript.h Fri Oct 20 17:05:01 2017<br>
> @@ -205,9 +205,12 @@ class LinkerScript final {<br>
> void setDot(Expr E, const Twine &Loc, bool InSec);<br>
><br>
> std::vector<InputSection *><br>
> - computeInputSections(const InputSectionDescription *);<br>
> + computeInputSections(const InputSectionDescription *,<br>
> + const llvm::DenseMap<SectionBase *, int> &Order);<br>
><br>
> - std::vector<InputSection *> createInputSectionList(<wbr>OutputSection &Cmd);<br>
> + std::vector<InputSection *><br>
> + createInputSectionList(<wbr>OutputSection &Cmd,<br>
> + const llvm::DenseMap<SectionBase *, int> &Order);<br>
><br>
> std::vector<size_t> getPhdrIndices(OutputSection *Sec);<br>
><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=4IyeZA5wFDIztRZwT5Ikft6eluO180gbHODF81Mf3Ug&s=aiE8jh76imSNJakqpdctbtvdseFdDLNUrnswv8Z4YiQ&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=http-3A__lists.<wbr>llvm.org_cgi-2Dbin_mailman_<wbr>listinfo_llvm-2Dcommits&d=<wbr>DwIGaQ&c=<wbr>5VD0RTtNlTh3ycd41b3MUw&r=<wbr>o3kDXzdBUE3ljQXKeTWOMw&m=<wbr>4IyeZA5wFDIztRZwT5Ikft6eluO180<wbr>gbHODF81Mf3Ug&s=<wbr>aiE8jh76imSNJakqpdctbtvdseFdDL<wbr>NUrnswv8Z4YiQ&e=</a><br>
><br>
</div></div></blockquote></div><br></div>