1## Check that BOLT handles correctly folding functions with --icf=safe that are only referenced from a .rela.data section. 2 3# REQUIRES: system-linux, asserts 4# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t1.o 5# RUN: %clang %cflags %t1.o -o %t.exe -Wl,-q -no-pie 6# RUN: llvm-bolt --no-threads %t.exe --icf -debug-only=bolt-icf -o %t.bolt 2>&1 | FileCheck --check-prefix=ICFCHECK %s 7# RUN: llvm-bolt --no-threads %t.exe --icf=safe -debug-only=bolt-icf -o %t.bolt 2>&1 | FileCheck --check-prefix=SAFEICFCHECK %s 8 9# ICFCHECK: ICF iteration 1 10# ICFCHECK-NEXT: folding barAddFunc into fooAddFunc 11 12# SAFEICFCHECK: skipping function with reference taken fooAddFunc 13# SAFEICFCHECK-NEXT: skipping function with reference taken barAddFunc 14# SAFEICFCHECK-NEXT: ICF iteration 1 15# SAFEICFCHECK-NEXT: ===--------- 16 17## clang++ main.cpp 18## Other functions removed for brevity. 19## int main(int argc, char **argv) { 20## const static int (*const funcGlobalBarAdd)(int, int) = barAddHdlper; 21## const int (* const funcGlobalBarMul)(int, int) = fooGlobalFuncHelper; 22## helper2(funcGlobalBarAdd, funcGlobalFooAdd, 3, 4) 23## } 24## Extra assembly removed. 25 26 .globl fooAddFunc 27 .type fooAddFunc,@function 28fooAddFunc: 29 addl -8(%rbp), %eax 30 retq 31 .size fooAddFunc, .-fooAddFunc 32 33 .globl barAddFunc 34 .type barAddFunc,@function 35barAddFunc: 36 addl -8(%rbp), %eax 37 retq 38 .size barAddFunc, .-barAddFunc 39 40 .globl helperFunc 41 .type helperFunc,@function 42helperFunc: 43 retq 44 .size helperFunc, .-helperFunc 45 46 .globl main 47 .type main,@function 48main: 49 movq localStaticVarBarAdd, %rdi 50 movq localStaticVarFooAdd, %rsi 51 callq helperFunc 52 retq 53 .size main, .-main 54 55 .type localStaticVarBarAdd,@object # @localStaticVarBarAdd 56 .data 57localStaticVarBarAdd: 58 .quad barAddFunc 59 .size localStaticVarBarAdd, 8 60 61 .type localStaticVarFooAdd,@object # @localStaticVarFooAdd 62localStaticVarFooAdd: 63 .quad fooAddFunc 64 .size localStaticVarFooAdd, 8 65