[PATCH] D127600: [lld-macho] Make `--icf=safe` work with LTO
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 12 07:31:06 PDT 2022
int3 created this revision.
int3 added a reviewer: lld-macho.
Herald added subscribers: ormris, steven_wu, hiraditya, inglorion.
Herald added projects: lld-macho, All.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127600
Files:
lld/MachO/LTO.cpp
lld/test/MachO/icf-safe.ll
lld/test/MachO/icf-safe.s
Index: lld/test/MachO/icf-safe.ll
===================================================================
--- lld/test/MachO/icf-safe.ll
+++ 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
Index: lld/MachO/LTO.cpp
===================================================================
--- lld/MachO/LTO.cpp
+++ lld/MachO/LTO.cpp
@@ -34,6 +34,7 @@
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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127600.436225.patch
Type: text/x-patch
Size: 2055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220612/472d3b71/attachment.bin>
More information about the llvm-commits
mailing list