mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-01 13:20:25 +00:00
ELF: Add -O0 (produce output as fast as possible) mode.
This patch redefines the default optimization level as 1 and adds new level 0. In the command line, it is -O0. The flag disables costly but optional features so that the linker produces semantically correct but larger output quickly. Currently it only disables section merging. This flag is not intended to be used for final production linking. It is intended to be used in compile-link-test cycle. Time to link clang with debug info is about 2x faster with the flag. Head: 13.24 seconds Output size: 1227189664 bytes With this patch: 7.41 seconds Output size: 2490281784 bytes Differential Revision: http://reviews.llvm.org/D19705 llvm-svn: 268056
This commit is contained in:
parent
0ccbfa3b44
commit
fb6d499ed7
@ -356,7 +356,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
|
||||
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));
|
||||
|
@ -143,6 +143,12 @@ elf::ObjectFile<ELFT>::getShtGroupEntries(const Elf_Shdr &Sec) {
|
||||
|
||||
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;
|
||||
|
@ -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",@progbits,1
|
||||
.asciz "abc"
|
||||
@ -55,6 +57,24 @@ zed:
|
||||
// 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 [
|
||||
|
Loading…
Reference in New Issue
Block a user