diff --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp --- a/lld/MachO/LTO.cpp +++ b/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(); diff --git a/lld/test/MachO/icf-safe.s b/lld/test/MachO/icf-safe.ll rename from lld/test/MachO/icf-safe.s rename to lld/test/MachO/icf-safe.ll --- 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