File: icp-inline.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (78 lines) | stat: -rw-r--r-- 2,205 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# 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-NOT: callq bar
# 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