[lld] [LLD] [MinGW] Hook up --icf=safe to -opt:safeicf (PR #70037)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 24 05:52:18 PDT 2023
https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/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
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.
>From 4a395f7b6543ee7d06d8ebc2c282f946e975e86f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Tue, 24 Oct 2023 15:47:35 +0300
Subject: [PATCH] [LLD] [MinGW] Hook up --icf=safe to -opt:safeicf
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?id=122818#inline-349280
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.
---
lld/MinGW/Driver.cpp | 4 +++-
lld/test/MinGW/driver.test | 6 ++++--
2 files changed, 7 insertions(+), 3 deletions(-)
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