[PATCH] D129803: [BOLT][TEST] Add icp-inline.s test
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 14 14:01:30 PDT 2022
Amir created this revision.
Herald added a reviewer: rafauler.
Herald added a subscriber: ayermolo.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
Add a test for `-icp-inline` knob, which ensures that ICP is only performed for
functions that can be subsequently inlined.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D129803
Files:
bolt/test/X86/icp-inline.s
Index: bolt/test/X86/icp-inline.s
===================================================================
--- /dev/null
+++ bolt/test/X86/icp-inline.s
@@ -0,0 +1,77 @@
+# This test verifies the effect of -icp-inline option: that ICP is only
+# performed for call targets eligible for inlining.
+
+# The assembly was produced from C code compiled with clang-15 -O1 -S:
+
+# int foo(int x) { return x + 1; }
+# int bar(int x) { return x*100 + 42; }
+# typedef int (*const fn)(int);
+# fn funcs[] = { foo, bar };
+#
+# int main(int argc, char *argv[]) {
+# fn func = funcs[argc];
+# return func(0);
+# }
+
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
+# RUN: link_fdata %s %t.o %t.fdata
+# RUN: llvm-strip --strip-unneeded %t.o
+# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib -pie
+
+# Without -icp-inline option, ICP is performed
+# RUN: llvm-bolt %t.exe --icp=calls --icp-calls-topn=1 --inline-small-functions\
+# RUN: -o /dev/null --lite=0 \
+# RUN: --inline-small-functions-bytes=4 --print-icp --data %t.fdata \
+# RUN: | FileCheck %s --check-prefix=CHECK-NO-ICP-INLINE
+# CHECK-NO-ICP-INLINE: Binary Function "main" after indirect-call-promotion
+# CHECK-NO-ICP-INLINE: callq bar
+# CHECK-NO-ICP-INLINE: End of Function "main"
+
+# With -icp-inline option, ICP is not performed (size of bar > inline threshold)
+# RUN: llvm-bolt %t.exe --icp=calls --icp-calls-topn=1 --inline-small-functions\
+# RUN: -o /dev/null --lite=0 \
+# RUN: --inline-small-functions-bytes=4 --icp-inline --print-icp \
+# RUN: --data %t.fdata | FileCheck %s --check-prefix=CHECK-ICP-INLINE
+# CHECK-ICP-INLINE: Binary Function "main" after indirect-call-promotion
+# CHECK-ICP-INLINE: callq *(%rcx,%rax,8)
+# CHECK-ICP-INLINE: End of Function "main"
+ .globl bar
+bar:
+ .cfi_startproc
+ imull $0x64, %edi, %eax
+ addl $0x2a, %eax
+ retq
+ .cfi_endproc
+.size bar, .-bar
+
+ .globl foo
+foo:
+ .cfi_startproc
+ leal 0x1(%rdi), %eax
+ retq
+ .cfi_endproc
+.size foo, .-foo
+
+ .globl main
+main:
+ .cfi_startproc
+ pushq %rax
+ .cfi_def_cfa_offset 16
+ movslq %edi, %rax
+ leaq funcs(%rip), %rcx
+ xorl %edi, %edi
+LBB00_br:
+ callq *(%rcx,%rax,8)
+# FDATA: 1 main #LBB00_br# 1 foo 0 0 1
+# FDATA: 1 main #LBB00_br# 1 bar 0 0 2
+ popq %rcx
+ .cfi_def_cfa_offset 8
+ retq
+ .cfi_endproc
+.size main, .-main
+
+ .data
+ .globl funcs
+funcs:
+ .quad foo
+ .quad bar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129803.444794.patch
Type: text/x-patch
Size: 2400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220714/d8692ec4/attachment.bin>
More information about the llvm-commits
mailing list