[lld] [LLD] [MinGW] Hook up --icf=safe to -opt:safeicf (PR #70037)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 24 05:52:57 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-coff
Author: Martin Storsjö (mstorsjo)
<details>
<summary>Changes</summary>
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
Later in 2021, lld-link did get support for safe ICF in 5bdc5e7efda4100c4d11085c2da8f1fb932ccce4 / https://reviews.llvm.org/D97436.
Hook this up for the MinGW frontend as well.
---
Full diff: https://github.com/llvm/llvm-project/pull/70037.diff
2 Files Affected:
- (modified) lld/MinGW/Driver.cpp (+3-1)
- (modified) lld/test/MinGW/driver.test (+4-2)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/70037
More information about the llvm-commits
mailing list