Add --icf=none option.

--icf=none negates --icf=all.

llvm-svn: 310526
This commit is contained in:
Rui Ueyama 2017-08-09 21:32:38 +00:00
parent ab04a08c49
commit ae704a5472
3 changed files with 26 additions and 2 deletions

View File

@ -637,7 +637,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
Config->Fini = Args.getLastArgValue(OPT_fini, "_fini");
Config->GcSections = getArg(Args, OPT_gc_sections, OPT_no_gc_sections, false);
Config->GdbIndex = Args.hasArg(OPT_gdb_index);
Config->ICF = Args.hasArg(OPT_icf);
Config->ICF = getArg(Args, OPT_icf_all, OPT_icf_none, false);
Config->Init = Args.getLastArgValue(OPT_init, "_init");
Config->LTOAAPipeline = Args.getLastArgValue(OPT_lto_aa_pipeline);
Config->LTONewPmPasses = Args.getLastArgValue(OPT_lto_newpm_passes);

View File

@ -139,7 +139,9 @@ defm hash_style: Eq<"hash-style">,
def help: F<"help">, HelpText<"Print option help">;
def icf: F<"icf=all">, HelpText<"Enable identical code folding">;
def icf_all: F<"icf=all">, HelpText<"Enable identical code folding">;
def icf_none: F<"icf=none">, HelpText<"Disable identical code folding">;
defm image_base : Eq<"image-base">, HelpText<"Set the base address">;

22
lld/test/ELF/icf-none.s Normal file
View File

@ -0,0 +1,22 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2 --icf=all --icf=none --verbose | FileCheck %s
# CHECK-NOT: selected .text.f1
.globl _start, f1, f2
_start:
ret
.section .text.f1, "ax"
f1:
mov $60, %rax
mov $42, %rdi
syscall
.section .text.f2, "ax"
f2:
mov $60, %rax
mov $42, %rdi
syscall