1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -verify -iroutliner -ir-outlining-no-cost < %s | FileCheck %s
4 ; This test checks that we do can outline calls, but only if they have the same
5 ; function type and the same name.
7 declare void @f1(i32*, i32*);
8 declare void @f2(i32*, i32*);
10 define void @function1() {
11 ; CHECK-LABEL: @function1(
13 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
14 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
15 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4
16 ; CHECK-NEXT: call void @outlined_ir_func_0(i32* [[A]], i32* [[B]], i32* [[C]])
17 ; CHECK-NEXT: ret void
20 %a = alloca i32, align 4
21 %b = alloca i32, align 4
22 %c = alloca i32, align 4
23 store i32 2, i32* %a, align 4
24 store i32 3, i32* %b, align 4
25 store i32 4, i32* %c, align 4
26 call void @f1(i32* %a, i32* %b)
27 %al = load i32, i32* %a
28 %bl = load i32, i32* %b
29 %cl = load i32, i32* %c
33 define void @function2() {
34 ; CHECK-LABEL: @function2(
36 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
37 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
38 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4
39 ; CHECK-NEXT: call void @outlined_ir_func_0(i32* [[A]], i32* [[B]], i32* [[C]])
40 ; CHECK-NEXT: ret void
43 %a = alloca i32, align 4
44 %b = alloca i32, align 4
45 %c = alloca i32, align 4
46 store i32 2, i32* %a, align 4
47 store i32 3, i32* %b, align 4
48 store i32 4, i32* %c, align 4
49 call void @f1(i32* %a, i32* %b)
50 %al = load i32, i32* %a
51 %bl = load i32, i32* %b
52 %cl = load i32, i32* %c
56 define void @function3() {
57 ; CHECK-LABEL: @function3(
59 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
60 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
61 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4
62 ; CHECK-NEXT: store i32 2, i32* [[A]], align 4
63 ; CHECK-NEXT: store i32 3, i32* [[B]], align 4
64 ; CHECK-NEXT: store i32 4, i32* [[C]], align 4
65 ; CHECK-NEXT: call void @f2(i32* [[A]], i32* [[B]])
66 ; CHECK-NEXT: [[AL:%.*]] = load i32, i32* [[A]], align 4
67 ; CHECK-NEXT: [[BL:%.*]] = load i32, i32* [[B]], align 4
68 ; CHECK-NEXT: [[CL:%.*]] = load i32, i32* [[C]], align 4
69 ; CHECK-NEXT: ret void
72 %a = alloca i32, align 4
73 %b = alloca i32, align 4
74 %c = alloca i32, align 4
75 store i32 2, i32* %a, align 4
76 store i32 3, i32* %b, align 4
77 store i32 4, i32* %c, align 4
78 call void @f2(i32* %a, i32* %b)
79 %al = load i32, i32* %a
80 %bl = load i32, i32* %b
81 %cl = load i32, i32* %c
85 ; CHECK: define internal void @outlined_ir_func_0(i32* [[ARG0:%.*]], i32* [[ARG1:%.*]], i32* [[ARG2:%.*]])
86 ; CHECK: entry_to_outline:
87 ; CHECK-NEXT: store i32 2, i32* [[ARG0]], align 4
88 ; CHECK-NEXT: store i32 3, i32* [[ARG1]], align 4
89 ; CHECK-NEXT: store i32 4, i32* [[ARG2]], align 4
90 ; CHECK-NEXT: call void @f1(i32* [[ARG0]], i32* [[ARG1]])
91 ; CHECK-NEXT: [[AL:%.*]] = load i32, i32* [[ARG0]], align 4
92 ; CHECK-NEXT: [[BL:%.*]] = load i32, i32* [[ARG1]], align 4
93 ; CHECK-NEXT: [[CL:%.*]] = load i32, i32* [[ARG2]], align 4