1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs
2 ; RUN: opt -S -passes=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(ptr, ptr);
8 declare void @f2(ptr, ptr);
10 define void @function1() {
12 %a = alloca i32, align 4
13 %b = alloca i32, align 4
14 %c = alloca i32, align 4
15 store i32 2, ptr %a, align 4
16 store i32 3, ptr %b, align 4
17 store i32 4, ptr %c, align 4
18 call void @f1(ptr %a, ptr %b)
19 %al = load i32, ptr %a
20 %bl = load i32, ptr %b
21 %cl = load i32, ptr %c
25 define void @function2() {
27 %a = alloca i32, align 4
28 %b = alloca i32, align 4
29 %c = alloca i32, align 4
30 store i32 2, ptr %a, align 4
31 store i32 3, ptr %b, align 4
32 store i32 4, ptr %c, align 4
33 call void @f1(ptr %a, ptr %b)
34 %al = load i32, ptr %a
35 %bl = load i32, ptr %b
36 %cl = load i32, ptr %c
40 define void @function3() {
42 %a = alloca i32, align 4
43 %b = alloca i32, align 4
44 %c = alloca i32, align 4
45 store i32 2, ptr %a, align 4
46 store i32 3, ptr %b, align 4
47 store i32 4, ptr %c, align 4
48 call void @f2(ptr %a, ptr %b)
49 %al = load i32, ptr %a
50 %bl = load i32, ptr %b
51 %cl = load i32, ptr %c
55 ; CHECK-LABEL: @function1(
57 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
58 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
59 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4
60 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]], ptr @f1)
61 ; CHECK-NEXT: ret void
64 ; CHECK-LABEL: @function2(
66 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
67 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
68 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4
69 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]], ptr @f1)
70 ; CHECK-NEXT: ret void
73 ; CHECK-LABEL: @function3(
75 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
76 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
77 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4
78 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]], ptr @f2)
79 ; CHECK-NEXT: ret void
82 ; CHECK-LABEL: define internal void @outlined_ir_func_0(
83 ; CHECK-NEXT: newFuncRoot:
84 ; CHECK-NEXT: br label [[ENTRY_TO_OUTLINE:%.*]]
85 ; CHECK: entry_to_outline:
86 ; CHECK-NEXT: store i32 2, ptr [[TMP0:%.*]], align 4
87 ; CHECK-NEXT: store i32 3, ptr [[TMP1:%.*]], align 4
88 ; CHECK-NEXT: store i32 4, ptr [[TMP2:%.*]], align 4
89 ; CHECK-NEXT: call void [[TMP3:%.*]](ptr [[TMP0]], ptr [[TMP1]])
90 ; CHECK-NEXT: [[AL:%.*]] = load i32, ptr [[TMP0]], align 4
91 ; CHECK-NEXT: [[BL:%.*]] = load i32, ptr [[TMP1]], align 4
92 ; CHECK-NEXT: [[CL:%.*]] = load i32, ptr [[TMP2]], align 4
93 ; CHECK-NEXT: br label [[ENTRY_AFTER_OUTLINE_EXITSTUB:%.*]]
94 ; CHECK: entry_after_outline.exitStub:
95 ; CHECK-NEXT: ret void