1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=verify,iroutliner --ir-outlining-no-cost < %s | FileCheck %s
3 ; RUN: opt -S -passes=verify,iroutliner -enable-linkonceodr-ir-outlining --ir-outlining-no-cost < %s | FileCheck -check-prefix=ODR %s
5 ; This test looks at the constants in the regions, and if it they are the
6 ; same it outlines them as constants rather than elevating them to arguments.
8 define linkonce_odr void @outline_odr1() {
9 ; ODR-LABEL: @outline_odr1(
11 ; ODR-NEXT: [[A:%.*]] = alloca i32, align 4
12 ; ODR-NEXT: [[B:%.*]] = alloca i32, align 4
13 ; ODR-NEXT: [[C:%.*]] = alloca i32, align 4
14 ; ODR-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]])
16 ; CHECK-LABEL: @outline_odr1(
18 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
19 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
20 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4
21 ; CHECK-NEXT: store i32 2, ptr [[A]], align 4
22 ; CHECK-NEXT: store i32 3, ptr [[B]], align 4
23 ; CHECK-NEXT: store i32 4, ptr [[C]], align 4
24 ; CHECK-NEXT: [[AL:%.*]] = load i32, ptr [[A]], align 4
25 ; CHECK-NEXT: [[BL:%.*]] = load i32, ptr [[B]], align 4
26 ; CHECK-NEXT: [[CL:%.*]] = load i32, ptr [[C]], align 4
28 %a = alloca i32, align 4
29 %b = alloca i32, align 4
30 %c = alloca i32, align 4
31 store i32 2, ptr %a, align 4
32 store i32 3, ptr %b, align 4
33 store i32 4, ptr %c, align 4
34 %al = load i32, ptr %a
35 %bl = load i32, ptr %b
36 %cl = load i32, ptr %c
40 define void @outline_odr2() {
41 ; ODR-LABEL: @outline_odr2(
43 ; ODR-NEXT: [[A:%.*]] = alloca i32, align 4
44 ; ODR-NEXT: [[B:%.*]] = alloca i32, align 4
45 ; ODR-NEXT: [[C:%.*]] = alloca i32, align 4
46 ; ODR-NEXT: call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]])
48 ; CHECK-LABEL: @outline_odr2(
50 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
51 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
52 ; CHECK-NEXT: [[C:%.*]] = alloca i32, align 4
53 ; CHECK-NEXT: store i32 2, ptr [[A]], align 4
54 ; CHECK-NEXT: store i32 3, ptr [[B]], align 4
55 ; CHECK-NEXT: store i32 4, ptr [[C]], align 4
56 ; CHECK-NEXT: [[AL:%.*]] = load i32, ptr [[A]], align 4
57 ; CHECK-NEXT: [[BL:%.*]] = load i32, ptr [[B]], align 4
58 ; CHECK-NEXT: [[CL:%.*]] = load i32, ptr [[C]], align 4
60 %a = alloca i32, align 4
61 %b = alloca i32, align 4
62 %c = alloca i32, align 4
63 store i32 2, ptr %a, align 4
64 store i32 3, ptr %b, align 4
65 store i32 4, ptr %c, align 4
66 %al = load i32, ptr %a
67 %bl = load i32, ptr %b
68 %cl = load i32, ptr %c