Skip to content

Commit 6d66440

Browse files
authored
[LLD] [MinGW] Hook up --icf=safe to -opt:safeicf (#70037)
Back when the --icf= option was hooked up in the MinGW frontend in LLD, in 2017, lld-link didn't support safe ICF, and mapping it to noicf was suggested in review: https://reviews.llvm.org/D40019 In 2018, in ab03802, lld-link did get support for handling address significance tables, allowing the ICF to operate safely on more sections. Later in 2021, lld-link did get support for a separate safe ICF mode in 5bdc5e7 / https://reviews.llvm.org/D97436. Hook this up for the MinGW frontend as well.
1 parent c4e9a43 commit 6d66440

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lld/MinGW/Driver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,9 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
375375
StringRef s = a->getValue();
376376
if (s == "all")
377377
add("-opt:icf");
378-
else if (s == "safe" || s == "none")
378+
else if (s == "safe")
379+
add("-opt:safeicf");
380+
else if (s == "none")
379381
add("-opt:noicf");
380382
else
381383
error("unknown parameter: --icf=" + s);

lld/test/MinGW/driver.test

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,12 @@ GC-SECTIONS: -opt:ref
205205
RUN: ld.lld -### -m i386pep foo.o 2>&1 | FileCheck -check-prefix ICF-NONE %s
206206
RUN: ld.lld -### -m i386pep foo.o --icf=none 2>&1 | FileCheck -check-prefix ICF-NONE %s
207207
RUN: ld.lld -### -m i386pep foo.o -icf=none 2>&1 | FileCheck -check-prefix ICF-NONE %s
208-
RUN: ld.lld -### -m i386pep foo.o --icf=safe 2>&1 | FileCheck -check-prefix ICF-NONE %s
209-
RUN: ld.lld -### -m i386pep foo.o -icf=safe 2>&1 | FileCheck -check-prefix ICF-NONE %s
210208
ICF-NONE: -opt:noicf
211209

210+
RUN: ld.lld -### -m i386pep foo.o --icf=safe 2>&1 | FileCheck -check-prefix ICF-SAFE %s
211+
RUN: ld.lld -### -m i386pep foo.o -icf=safe 2>&1 | FileCheck -check-prefix ICF-SAFE %s
212+
ICF-SAFE: -opt:safeicf
213+
212214
RUN: ld.lld -### -m i386pep foo.o --icf=all 2>&1 | FileCheck -check-prefix ICF %s
213215
RUN: ld.lld -### -m i386pep foo.o -icf=all 2>&1 | FileCheck -check-prefix ICF %s
214216
RUN: ld.lld -### -m i386pep foo.o --icf all 2>&1 | FileCheck -check-prefix ICF %s

0 commit comments

Comments
 (0)