<p dir="ltr"><br>
On Jan 29, 2015 4:46 AM, "Rafael Espindola" <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
><br>
> Author: rafael<br>
> Date: Thu Jan 29 06:43:28 2015<br>
> New Revision: 227431<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=227431&view=rev">http://llvm.org/viewvc/llvm-project?rev=227431&view=rev</a><br>
> Log:<br>
> Don't create multiple mergeable sections with -fdata-sections.<br>
><br>
> ELF has support for sections that can be split into fixed size or<br>
> null terminated entities.<br>
><br>
> Since these sections can be split by the linker, it is not necessary<br>
> to split them in codegen.<br>
><br>
> This reduces the combined .o size in a llvm+clang build from<br>
> 202,394,570 to 173,819,098 bytes.</p>
<p dir="ltr">Nice! - though the linked binary size is essentially the same (bar the rodata you mentioned below - hmm, chrome is fussy about executable size...)? </p>
<p dir="ltr">><br>
> The time for linking clang with gold (on a VM, on a laptop) goes<br>
> from 2.250089985 to 1.383001792 seconds.</p>
<p dir="ltr">That sounds pretty awesome! Though I thought my gold links even on my non-virtual beefy desktop were longer than that. Perhaps not.</p>
<p dir="ltr">><br>
> The flip side is the size of rodata in clang goes from 10,926,785<br>
> to 10,929,345 bytes.<br>
><br>
> The increase seems to be because of <a href="http://sourceware.org/bugzilla/show_bug.cgi?id=17902">http://sourceware.org/bugzilla/show_bug.cgi?id=17902</a>.<br>
><br>
> Modified:<br>
> llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp<br>
> llvm/trunk/test/CodeGen/X86/global-sections.ll<br>
><br>
> Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=227431&r1=227430&r2=227431&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=227431&r1=227430&r2=227431&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)<br>
> +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Thu Jan 29 06:43:28 2015<br>
> @@ -246,24 +246,25 @@ static StringRef getSectionPrefixForGlob<br>
> const MCSection *TargetLoweringObjectFileELF::<br>
> SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,<br>
> Mangler &Mang, const TargetMachine &TM) const {<br>
> + unsigned Flags = getELFSectionFlags(Kind);<br>
> +<br>
> // If we have -ffunction-section or -fdata-section then we should emit the<br>
> // global value to a uniqued section specifically for it.<br>
> - bool EmitUniquedSection;<br>
> - if (Kind.isText())<br>
> - EmitUniquedSection = TM.getFunctionSections();<br>
> - else<br>
> - EmitUniquedSection = TM.getDataSections();<br>
> + bool EmitUniquedSection = false;<br>
> + if (!(Flags & ELF::SHF_MERGE) && !Kind.isCommon()) {<br>
> + if (Kind.isText())<br>
> + EmitUniquedSection = TM.getFunctionSections();<br>
> + else<br>
> + EmitUniquedSection = TM.getDataSections();<br>
> + }<br>
><br>
> - // If this global is linkonce/weak and the target handles this by emitting it<br>
> - // into a 'uniqued' section name, create and return the section now.<br>
> - if ((EmitUniquedSection && !Kind.isCommon()) || GV->hasComdat()) {<br>
> + if (EmitUniquedSection || GV->hasComdat()) {<br>
> StringRef Prefix = getSectionPrefixForGlobal(Kind);<br>
><br>
> SmallString<128> Name(Prefix);<br>
> TM.getNameWithPrefix(Name, GV, Mang, true);<br>
><br>
> StringRef Group = "";<br>
> - unsigned Flags = getELFSectionFlags(Kind);<br>
> if (const Comdat *C = getELFComdat(GV)) {<br>
> Flags |= ELF::SHF_GROUP;<br>
> Group = C->getName();<br>
><br>
> Modified: llvm/trunk/test/CodeGen/X86/global-sections.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections.ll?rev=227431&r1=227430&r2=227431&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections.ll?rev=227431&r1=227430&r2=227431&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/test/CodeGen/X86/global-sections.ll (original)<br>
> +++ llvm/trunk/test/CodeGen/X86/global-sections.ll Thu Jan 29 06:43:28 2015<br>
> @@ -121,7 +121,7 @@ define void @F1() {<br>
> ; LINUX: G7:<br>
> ; LINUX: .asciz "abcdefghi"<br>
><br>
> -; LINUX-SECTIONS: .section .rodata.G7,"aMS",@progbits,1<br>
> +; LINUX-SECTIONS: .section .rodata.str1.1,"aMS",@progbits,1<br>
> ; LINUX-SECTIONS: .globl G7<br>
><br>
> ; WIN32-SECTIONS: .section .rdata,"rd",one_only,_G7<br>
> @@ -182,7 +182,7 @@ define void @F1() {<br>
> @G14 = private unnamed_addr constant [4 x i8] c"foo\00", align 1<br>
><br>
> ; LINUX-SECTIONS: .type .LG14,@object # @G14<br>
> -; LINUX-SECTIONS: .section .rodata..LG14,"aMS",@progbits,1<br>
> +; LINUX-SECTIONS: .section .rodata.str1.1,"aMS",@progbits,1<br>
> ; LINUX-SECTIONS: .LG14:<br>
> ; LINUX-SECTIONS: .asciz "foo"<br>
> ; LINUX-SECTIONS: .size .LG14, 4<br>
> @@ -206,7 +206,7 @@ define void @F1() {<br>
> ; DARWIN64: .section __TEXT,__const<br>
> ; DARWIN64: _G15:<br>
><br>
> -; LINUX-SECTIONS: .section .rodata.G15,"aM",@progbits,8<br>
> +; LINUX-SECTIONS: .section .rodata.cst8,"aM",@progbits,8<br>
> ; LINUX-SECTIONS: G15:<br>
><br>
> ; WIN32-SECTIONS: .section .rdata,"rd",one_only,_G15<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</p>