Skip to content

Commit afa51f6

Browse files
committed
llvm-reduce: Add new pass to inline call sites
Added a primitive heuristic to avoid blowing up the code size which could use more thought. This helps cleanup some basic examples I've been looking at where there is a worse result when just running a bug through the full optimization pipeline vs. running just a single pass at the point of failure.
1 parent b3f6884 commit afa51f6

File tree

7 files changed

+984
-1
lines changed

7 files changed

+984
-1
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=inline-call-sites -reduce-callsite-inline-threshold=3 --test FileCheck --test-arg --check-prefix=CHECK --test-arg %s --test-arg --input-file %s -o %t
2+
; RUN: FileCheck -check-prefixes=RESULT,CHECK %s < %t
3+
4+
declare void @extern_b()
5+
declare void @extern_a()
6+
7+
; RESULT: @gv_init = global ptr @no_inline_noncall_user
8+
@gv_init = global ptr @no_inline_noncall_user
9+
10+
11+
; CHECK-LABEL: define void @no_inline_noncall_user(
12+
define void @no_inline_noncall_user() {
13+
call void @extern_a()
14+
call void @extern_a()
15+
call void @extern_a()
16+
call void @extern_a()
17+
ret void
18+
}
19+
20+
; RESULT-LABEL: define void @noncall_user_call() {
21+
; RESULT-NEXT: call void @no_inline_noncall_user()
22+
; RESULT-NEXT: ret void
23+
define void @noncall_user_call() {
24+
call void @no_inline_noncall_user()
25+
ret void
26+
}
27+
28+
; RESULT-LABEL: define void @big_callee_small_caller_callee() {
29+
define void @big_callee_small_caller_callee() {
30+
call void @extern_a()
31+
call void @extern_a()
32+
call void @extern_a()
33+
call void @extern_a()
34+
ret void
35+
}
36+
37+
; RESULT-LABEL: define void @big_callee_small_caller_caller() {
38+
; RESULT-NEXT: call void @extern_b()
39+
; RESULT-NEXT: call void @extern_a()
40+
; RESULT-NEXT: call void @extern_a()
41+
; RESULT-NEXT: call void @extern_a()
42+
; RESULT-NEXT: call void @extern_a()
43+
; RESULT-NEXT: ret void
44+
define void @big_callee_small_caller_caller() {
45+
call void @extern_b()
46+
call void @big_callee_small_caller_callee()
47+
ret void
48+
}
49+
50+
; RESULT-LABEL: define void @small_callee_big_caller_callee() {
51+
; RESULT-NEXT: call void @extern_a()
52+
; RESULT-NEXT: ret void
53+
define void @small_callee_big_caller_callee() {
54+
call void @extern_a()
55+
ret void
56+
}
57+
58+
; RESULT-LABEL: define void @small_callee_big_caller_caller() {
59+
; RESULT-NEXT: call void @extern_b()
60+
; RESULT-NEXT: call void @extern_a()
61+
; RESULT-NEXT: call void @extern_b()
62+
; RESULT-NEXT: call void @extern_b()
63+
; RESULT-NEXT: ret void
64+
define void @small_callee_big_caller_caller() {
65+
call void @extern_b()
66+
call void @small_callee_big_caller_callee()
67+
call void @extern_b()
68+
call void @extern_b()
69+
ret void
70+
}
71+
72+
; RESULT-LABEL: define void @big_callee_big_caller_callee() {
73+
define void @big_callee_big_caller_callee() {
74+
call void @extern_a()
75+
call void @extern_a()
76+
call void @extern_a()
77+
call void @extern_a()
78+
ret void
79+
}
80+
81+
; RESULT-LABEL: define void @big_callee_big_caller_caller() {
82+
; RESULT-NEXT: call void @extern_b()
83+
; RESULT-NEXT: call void @big_callee_big_caller_callee()
84+
; RESULT-NEXT: call void @extern_b()
85+
; RESULT-NEXT: call void @extern_b()
86+
; RESULT-NEXT: call void @extern_b()
87+
; RESULT-NEXT: ret void
88+
define void @big_callee_big_caller_caller() {
89+
call void @extern_b()
90+
call void @big_callee_big_caller_callee()
91+
call void @extern_b()
92+
call void @extern_b()
93+
call void @extern_b()
94+
ret void
95+
}

0 commit comments

Comments
 (0)