[lld] d378268 - [lld-macho] Make `--icf=safe` work with LTO
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 12 14:33:07 PDT 2022
Author: Jez Ng
Date: 2022-06-12T17:26:08-04:00
New Revision: d378268ead93c85803c270277f0243737b536ae7
URL: https://github.com/llvm/llvm-project/commit/d378268ead93c85803c270277f0243737b536ae7
DIFF: https://github.com/llvm/llvm-project/commit/d378268ead93c85803c270277f0243737b536ae7.diff
LOG: [lld-macho] Make `--icf=safe` work with LTO
Just matter of enabling the config option.
(Also changed the platform of the input test file to macOS, since that's
the default that we specify in the `%lld` substitution. The conflict was
causing errors when linking with LTO.)
Reviewed By: #lld-macho, thakis
Differential Revision: https://reviews.llvm.org/D127600
Added:
lld/test/MachO/icf-safe.ll
Modified:
lld/MachO/LTO.cpp
Removed:
lld/test/MachO/icf-safe.s
################################################################################
diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp
index b921704f26fca..e87c4c4131069 100644
--- a/lld/MachO/LTO.cpp
+++ b/lld/MachO/LTO.cpp
@@ -34,6 +34,7 @@ using namespace llvm::sys;
static lto::Config createConfig() {
lto::Config c;
c.Options = initTargetOptionsFromCodeGenFlags();
+ c.Options.EmitAddrsig = config->icfLevel == ICFLevel::safe;
c.CodeModel = getCodeModelFromCMModel();
c.CPU = getCPUStr();
c.MAttrs = getMAttrs();
diff --git a/lld/test/MachO/icf-safe.s b/lld/test/MachO/icf-safe.ll
similarity index 77%
rename from lld/test/MachO/icf-safe.s
rename to lld/test/MachO/icf-safe.ll
index ceb324e48a0f3..71c6f9f7ddac8 100644
--- a/lld/test/MachO/icf-safe.s
+++ b/lld/test/MachO/icf-safe.ll
@@ -1,10 +1,19 @@
+; REQUIRES: aarch64
+
; RUN: rm -rf %t; mkdir %t
-; RUN: llc -filetype=obj %s -O3 -o %t/icf-obj.o -enable-machine-outliner=never -mtriple arm64-apple-ios -addrsig
+
+; RUN: llc -filetype=obj %s -O3 -o %t/icf-obj.o -enable-machine-outliner=never -mtriple arm64-apple-macos -addrsig
; RUN: %lld -arch arm64 -lSystem --icf=safe -dylib -o %t/icf-safe.dylib %t/icf-obj.o
; RUN: %lld -arch arm64 -lSystem --icf=all -dylib -o %t/icf-all.dylib %t/icf-obj.o
; RUN: llvm-objdump %t/icf-safe.dylib -d --macho | FileCheck %s --check-prefix=ICFSAFE
; RUN: llvm-objdump %t/icf-all.dylib -d --macho | FileCheck %s --check-prefix=ICFALL
+; RUN: llvm-as %s -o %t/icf-bitcode.o
+; RUN: %lld -arch arm64 -lSystem --icf=safe -dylib -o %t/icf-safe-bitcode.dylib %t/icf-bitcode.o
+; RUN: %lld -arch arm64 -lSystem --icf=all -dylib -o %t/icf-all-bitcode.dylib %t/icf-bitcode.o
+; RUN: llvm-objdump %t/icf-safe-bitcode.dylib -d --macho | FileCheck %s --check-prefix=ICFSAFE
+; RUN: llvm-objdump %t/icf-all-bitcode.dylib -d --macho | FileCheck %s --check-prefix=ICFALL
+
; ICFSAFE-LABEL: _callAllFunctions
; ICFSAFE: bl _func02
; ICFSAFE-NEXT: bl _func02
@@ -15,10 +24,8 @@
; ICFALL-NEXT: bl _func03_takeaddr
; ICFALL-NEXT: bl _func03_takeaddr
-; REQUIRES: aarch64
-
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
-target triple = "arm64-apple-ios7.0.0"
+target triple = "arm64-apple-macos11.0"
@result = global i32 0, align 4
More information about the llvm-commits
mailing list