[lld] 6d66440 - [LLD] [MinGW] Hook up --icf=safe to -opt:safeicf (#70037)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 25 04:38:34 PDT 2023
Author: Martin Storsjö
Date: 2023-10-25T14:38:30+03:00
New Revision: 6d66440c50e3047b5ce152830d4ccae381c7c2bf
URL: https://github.com/llvm/llvm-project/commit/6d66440c50e3047b5ce152830d4ccae381c7c2bf
DIFF: https://github.com/llvm/llvm-project/commit/6d66440c50e3047b5ce152830d4ccae381c7c2bf.diff
LOG: [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 ab038025a50c79a89edb5832b163e8c729ceb703,
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
5bdc5e7efda4100c4d11085c2da8f1fb932ccce4 /
https://reviews.llvm.org/D97436.
Hook this up for the MinGW frontend as well.
Added:
Modified:
lld/MinGW/Driver.cpp
lld/test/MinGW/driver.test
Removed:
################################################################################
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index 8fc9ac54d04a2d1..19bf2d1617057eb 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -375,7 +375,9 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
StringRef s = a->getValue();
if (s == "all")
add("-opt:icf");
- else if (s == "safe" || s == "none")
+ else if (s == "safe")
+ add("-opt:safeicf");
+ else if (s == "none")
add("-opt:noicf");
else
error("unknown parameter: --icf=" + s);
diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index 1fdd494754af4bf..a07c95edb580da1 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -205,10 +205,12 @@ GC-SECTIONS: -opt:ref
RUN: ld.lld -### -m i386pep foo.o 2>&1 | FileCheck -check-prefix ICF-NONE %s
RUN: ld.lld -### -m i386pep foo.o --icf=none 2>&1 | FileCheck -check-prefix ICF-NONE %s
RUN: ld.lld -### -m i386pep foo.o -icf=none 2>&1 | FileCheck -check-prefix ICF-NONE %s
-RUN: ld.lld -### -m i386pep foo.o --icf=safe 2>&1 | FileCheck -check-prefix ICF-NONE %s
-RUN: ld.lld -### -m i386pep foo.o -icf=safe 2>&1 | FileCheck -check-prefix ICF-NONE %s
ICF-NONE: -opt:noicf
+RUN: ld.lld -### -m i386pep foo.o --icf=safe 2>&1 | FileCheck -check-prefix ICF-SAFE %s
+RUN: ld.lld -### -m i386pep foo.o -icf=safe 2>&1 | FileCheck -check-prefix ICF-SAFE %s
+ICF-SAFE: -opt:safeicf
+
RUN: ld.lld -### -m i386pep foo.o --icf=all 2>&1 | FileCheck -check-prefix ICF %s
RUN: ld.lld -### -m i386pep foo.o -icf=all 2>&1 | FileCheck -check-prefix ICF %s
RUN: ld.lld -### -m i386pep foo.o --icf all 2>&1 | FileCheck -check-prefix ICF %s
More information about the llvm-commits
mailing list