[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 14:33:03 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd378268ead93: [lld-macho] Make `--icf=safe` work with LTO (authored by int3).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127600/new/

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.436253.patch
Type: text/x-patch
Size: 2055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220612/5bbab905/attachment.bin>


More information about the llvm-commits mailing list