1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost -ir-sim-calls-by-name < %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(ptr, ptr);
8 declare void @f2(ptr, ptr);
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(ptr [[A]], ptr [[B]], ptr [[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, ptr %a, align 4
24 store i32 3, ptr %b, align 4
25 store i32 4, ptr %c, align 4
26 call void @f1(ptr %a, ptr %b)
27 %al = load i32, ptr %a
28 %bl = load i32, ptr %b
29 %cl = load i32, ptr %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(ptr [[A]], ptr [[B]], ptr [[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, ptr %a, align 4
47 store i32 3, ptr %b, align 4
48 store i32 4, ptr %c, align 4
49 call void @f1(ptr %a, ptr %b)
50 %al = load i32, ptr %a
51 %bl = load i32, ptr %b
52 %cl = load i32, ptr %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, ptr [[A]], align 4
63 ; CHECK-NEXT: store i32 3, ptr [[B]], align 4
64 ; CHECK-NEXT: store i32 4, ptr [[C]], align 4
65 ; CHECK-NEXT: call void @f2(ptr [[A]], ptr [[B]])
66 ; CHECK-NEXT: [[AL:%.*]] = load i32, ptr [[A]], align 4
67 ; CHECK-NEXT: [[BL:%.*]] = load i32, ptr [[B]], align 4
68 ; CHECK-NEXT: [[CL:%.*]] = load i32, ptr [[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, ptr %a, align 4
76 store i32 3, ptr %b, align 4
77 store i32 4, ptr %c, align 4
78 call void @f2(ptr %a, ptr %b)
79 %al = load i32, ptr %a
80 %bl = load i32, ptr %b
81 %cl = load i32, ptr %c
85 ; CHECK: define internal void @outlined_ir_func_0(ptr [[ARG0:%.*]], ptr [[ARG1:%.*]], ptr [[ARG2:%.*]])
86 ; CHECK: entry_to_outline:
87 ; CHECK-NEXT: store i32 2, ptr [[ARG0]], align 4
88 ; CHECK-NEXT: store i32 3, ptr [[ARG1]], align 4
89 ; CHECK-NEXT: store i32 4, ptr [[ARG2]], align 4
90 ; CHECK-NEXT: call void @f1(ptr [[ARG0]], ptr [[ARG1]])
91 ; CHECK-NEXT: [[AL:%.*]] = load i32, ptr [[ARG0]], align 4
92 ; CHECK-NEXT: [[BL:%.*]] = load i32, ptr [[ARG1]], align 4
93 ; CHECK-NEXT: [[CL:%.*]] = load i32, ptr [[ARG2]], align 4