3 ; RUN: rm -rf %t; mkdir %t
5 ; RUN: llc -filetype=obj %s -O3 -o %t/icf-obj.o -enable-machine-outliner=never -mtriple arm64-apple-macos -addrsig
6 ; RUN: %lld -arch arm64 -lSystem --icf=safe -dylib -o %t/icf-safe.dylib %t/icf-obj.o
7 ; RUN: %lld -arch arm64 -lSystem --icf=all -dylib -o %t/icf-all.dylib %t/icf-obj.o
8 ; RUN: llvm-objdump %t/icf-safe.dylib -d --macho | FileCheck %s --check-prefix=ICFSAFE
9 ; RUN: llvm-objdump %t/icf-all.dylib -d --macho | FileCheck %s --check-prefix=ICFALL
11 ; RUN: llvm-as %s -o %t/icf-bitcode.o
12 ; RUN: %lld -arch arm64 -lSystem --icf=safe -dylib -o %t/icf-safe-bitcode.dylib %t/icf-bitcode.o
13 ; RUN: %lld -arch arm64 -lSystem --icf=all -dylib -o %t/icf-all-bitcode.dylib %t/icf-bitcode.o
14 ; RUN: llvm-objdump %t/icf-safe-bitcode.dylib -d --macho | FileCheck %s --check-prefix=ICFSAFE
15 ; RUN: llvm-objdump %t/icf-all-bitcode.dylib -d --macho | FileCheck %s --check-prefix=ICFALL
17 ; ICFSAFE-LABEL: _callAllFunctions
19 ; ICFSAFE-NEXT: bl _func02
20 ; ICFSAFE-NEXT: bl _func03_takeaddr
22 ; ICFALL-LABEL: _callAllFunctions
23 ; ICFALL: bl _func03_takeaddr
24 ; ICFALL-NEXT: bl _func03_takeaddr
25 ; ICFALL-NEXT: bl _func03_takeaddr
27 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
28 target triple = "arm64-apple-macos11.0"
30 @result = global i32 0, align 4
32 define void @func01() local_unnamed_addr noinline {
34 %0 = load volatile i32, ptr @result, align 4
35 %add = add nsw i32 %0, 1
36 store volatile i32 %add, ptr @result, align 4
40 define void @func02() local_unnamed_addr noinline {
42 %0 = load volatile i32, ptr @result, align 4
43 %add = add nsw i32 %0, 1
44 store volatile i32 %add, ptr @result, align 4
48 define void @func03_takeaddr() noinline {
50 %0 = load volatile i32, ptr @result, align 4
51 %add = add nsw i32 %0, 1
52 store volatile i32 %add, ptr @result, align 4
56 define void @callAllFunctions() local_unnamed_addr {
58 tail call void @func01()
59 tail call void @func02()
60 tail call void @func03_takeaddr()
61 %0 = load volatile i32, ptr @result, align 4
62 %add = add nsw i32 %0, ptrtoint (ptr @func03_takeaddr to i32)
63 store volatile i32 %add, ptr @result, align 4