xref: /llvm-project/llvm/test/Transforms/IROutliner/outlining-odr.ll (revision f4b925ee7078f058602fd323e25f45f1ae91ca34)
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
4
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.
7
8define linkonce_odr void @outline_odr1() {
9; ODR-LABEL: @outline_odr1(
10; ODR-NEXT:  entry:
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]])
15; ODR-NEXT:    ret void
16; CHECK-LABEL: @outline_odr1(
17; CHECK-NEXT:  entry:
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
27entry:
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
37  ret void
38}
39
40define void @outline_odr2() {
41; ODR-LABEL: @outline_odr2(
42; ODR-NEXT:  entry:
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]])
47; ODR-NEXT:    ret void
48; CHECK-LABEL: @outline_odr2(
49; CHECK-NEXT:  entry:
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
59entry:
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
69  ret void
70}
71