Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / bolt / test / X86 / icp-inline.s
blob318318f96215c26a67c2fb942218ee4a72cc18eb
1 # This test verifies the effect of -icp-inline option: that ICP is only
2 # performed for call targets eligible for inlining.
4 # The assembly was produced from C code compiled with clang-15 -O1 -S:
6 # int foo(int x) { return x + 1; }
7 # int bar(int x) { return x*100 + 42; }
8 # typedef int (*const fn)(int);
9 # fn funcs[] = { foo, bar };
11 # int main(int argc, char *argv[]) {
12 # fn func = funcs[argc];
13 # return func(0);
14 # }
16 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
17 # RUN: link_fdata %s %t.o %t.fdata
18 # RUN: llvm-strip --strip-unneeded %t.o
19 # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib -pie
21 # Without -icp-inline option, ICP is performed
22 # RUN: llvm-bolt %t.exe --icp=calls --icp-calls-topn=1 --inline-small-functions\
23 # RUN: -o /dev/null --lite=0 \
24 # RUN: --inline-small-functions-bytes=4 --print-icp --data %t.fdata \
25 # RUN: | FileCheck %s --check-prefix=CHECK-NO-ICP-INLINE
26 # CHECK-NO-ICP-INLINE: Binary Function "main" after indirect-call-promotion
27 # CHECK-NO-ICP-INLINE: callq bar
28 # CHECK-NO-ICP-INLINE: End of Function "main"
30 # With -icp-inline option, ICP is not performed (size of bar > inline threshold)
31 # RUN: llvm-bolt %t.exe --icp=calls --icp-calls-topn=1 --inline-small-functions\
32 # RUN: -o /dev/null --lite=0 \
33 # RUN: --inline-small-functions-bytes=4 --icp-inline --print-icp \
34 # RUN: --data %t.fdata | FileCheck %s --check-prefix=CHECK-ICP-INLINE
35 # CHECK-ICP-INLINE: Binary Function "main" after indirect-call-promotion
36 # CHECK-ICP-INLINE: callq *(%rcx,%rax,8)
37 # CHECK-ICP-INLINE-NOT: callq bar
38 # CHECK-ICP-INLINE: End of Function "main"
39 .globl bar
40 bar:
41 .cfi_startproc
42 imull $0x64, %edi, %eax
43 addl $0x2a, %eax
44 retq
45 .cfi_endproc
46 .size bar, .-bar
48 .globl foo
49 foo:
50 .cfi_startproc
51 leal 0x1(%rdi), %eax
52 retq
53 .cfi_endproc
54 .size foo, .-foo
56 .globl main
57 main:
58 .cfi_startproc
59 pushq %rax
60 .cfi_def_cfa_offset 16
61 movslq %edi, %rax
62 leaq funcs(%rip), %rcx
63 xorl %edi, %edi
64 LBB00_br:
65 callq *(%rcx,%rax,8)
66 # FDATA: 1 main #LBB00_br# 1 foo 0 0 1
67 # FDATA: 1 main #LBB00_br# 1 bar 0 0 2
68 popq %rcx
69 .cfi_def_cfa_offset 8
70 retq
71 .cfi_endproc
72 .size main, .-main
74 .data
75 .globl funcs
76 funcs:
77 .quad foo
78 .quad bar