[PATCH] D19705: ELF: Add "fast link" mode.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 09:18:29 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL268056: ELF: Add -O0 (produce output as fast as possible) mode. (authored by ruiu).

Changed prior to commit:
  http://reviews.llvm.org/D19705?vs=55522&id=55611#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19705

Files:
  lld/trunk/ELF/Driver.cpp
  lld/trunk/ELF/InputFiles.cpp
  lld/trunk/test/ELF/merge-string.s

Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -356,7 +356,7 @@
   Config->SoName = getString(Args, OPT_soname);
   Config->Sysroot = getString(Args, OPT_sysroot);
 
-  Config->Optimize = getInteger(Args, OPT_O, 0);
+  Config->Optimize = getInteger(Args, OPT_O, 1);
   Config->LtoO = getInteger(Args, OPT_lto_O, 2);
   if (Config->LtoO > 3)
     error("invalid optimization level for LTO: " + getString(Args, OPT_lto_O));
Index: lld/trunk/ELF/InputFiles.cpp
===================================================================
--- lld/trunk/ELF/InputFiles.cpp
+++ lld/trunk/ELF/InputFiles.cpp
@@ -143,6 +143,12 @@
 
 template <class ELFT> static bool shouldMerge(const typename ELFT::Shdr &Sec) {
   typedef typename ELFT::uint uintX_t;
+
+  // We don't merge sections if -O0 (default is -O1). This makes sometimes
+  // the linker significantly faster, although the output will be bigger.
+  if (Config->Optimize == 0)
+    return false;
+
   uintX_t Flags = Sec.sh_flags;
   if (!(Flags & SHF_MERGE))
     return false;
Index: lld/trunk/test/ELF/merge-string.s
===================================================================
--- lld/trunk/test/ELF/merge-string.s
+++ lld/trunk/test/ELF/merge-string.s
@@ -4,6 +4,8 @@
 // RUN: llvm-readobj -s -section-data -t %t.so | FileCheck %s
 // RUN: ld.lld -O1 %t.o -o %t.so -shared
 // RUN: llvm-readobj -s -section-data -t %t.so | FileCheck --check-prefix=NOTAIL %s
+// RUN: ld.lld -O0 %t.o -o %t.so -shared
+// RUN: llvm-readobj -s -section-data -t %t.so | FileCheck --check-prefix=NOMERGE %s
 
         .section	.rodata.str1.1,"aMS", at progbits,1
 	.asciz	"abc"
@@ -55,6 +57,24 @@
 // NOTAIL-NEXT:   0000: 61626300 626300                     |abc.bc.|
 // NOTAIL-NEXT: )
 
+// NOMERGE:      Name:    .rodata
+// NOMERGE-NEXT: Type:    SHT_PROGBITS
+// NOMERGE-NEXT: Flags [
+// NOMERGE-NEXT:   SHF_ALLOC
+// NOMERGE-NEXT:   SHF_MERGE
+// NOMERGE-NEXT:   SHF_STRINGS
+// NOMERGE-NEXT: ]
+// NOMERGE-NEXT: Address:         0x1C8
+// NOMERGE-NEXT: Offset:  0x1C8
+// NOMERGE-NEXT: Size:    16
+// NOMERGE-NEXT: Link: 0
+// NOMERGE-NEXT: Info: 0
+// NOMERGE-NEXT: AddressAlignment: 2
+// NOMERGE-NEXT: EntrySize: 0
+// NOMERGE-NEXT: SectionData (
+// NOMERGE-NEXT:   0000: 61626300 61626300 62630000 14000000  |abc.abc.bc......|
+// NOMERGE-NEXT: )
+
 // CHECK:      Name: .rodata
 // CHECK-NEXT: Type: SHT_PROGBITS
 // CHECK-NEXT: Flags [


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19705.55611.patch
Type: text/x-patch
Size: 2496 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160429/e5883bd8/attachment.bin>


More information about the llvm-commits mailing list