brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · c5106db Raw
79 lines · plain
1## This test verifies the effect of -icp-inline option: that ICP is only2## performed for call targets eligible for inlining.3 4## The assembly was produced from C code compiled with clang-15 -O1 -S:5 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 };10#11# int main(int argc, char *argv[]) {12#   fn func = funcs[argc];13#   return func(0);14# }15 16# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o17# RUN: link_fdata %s %t.o %t.fdata18# RUN: llvm-strip --strip-unneeded %t.o19# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib -pie20 21# Without -icp-inline option, ICP is performed22# RUN: llvm-bolt %t.exe --icp=calls --icp-calls-topn=1 --inline-small-functions\23# RUN:   -o %t.null --lite=0 \24# RUN:   --inline-small-functions-bytes=4 --print-icp --data %t.fdata \25# RUN:   | FileCheck %s --check-prefix=CHECK-NO-ICP-INLINE26# CHECK-NO-ICP-INLINE: Binary Function "main" after indirect-call-promotion27# CHECK-NO-ICP-INLINE: callq bar28# CHECK-NO-ICP-INLINE: End of Function "main"29 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 %t.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-INLINE35# CHECK-ICP-INLINE:     Binary Function "main" after indirect-call-promotion36# CHECK-ICP-INLINE:     callq *(%rcx,%rax,8)37# CHECK-ICP-INLINE-NOT: callq bar38# CHECK-ICP-INLINE:     End of Function "main"39  .globl bar40bar:41	.cfi_startproc42	imull	$0x64, %edi, %eax43	addl	$0x2a, %eax44	retq45	.cfi_endproc46.size bar, .-bar47 48  .globl foo49foo:50	.cfi_startproc51	leal	0x1(%rdi), %eax52	retq53	.cfi_endproc54.size foo, .-foo55 56  .globl main57main:58	.cfi_startproc59  pushq %rax60  .cfi_def_cfa_offset 1661  movslq  %edi, %rax62  leaq  funcs(%rip), %rcx63  xorl  %edi, %edi64LBB00_br:65  callq *(%rcx,%rax,8)66# FDATA: 1 main #LBB00_br# 1 foo 0 0 167# FDATA: 1 main #LBB00_br# 1 bar 0 0 268  popq  %rcx69  .cfi_def_cfa_offset 870  retq71	.cfi_endproc72.size main, .-main73 74	.data75	.globl	funcs76funcs:77	.quad	foo78	.quad	bar79