xref: /llvm-project/llvm/test/Transforms/IROutliner/outlining-compatible-or-attribute-transfer.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
4; This has two compatible regions.  We have attributes that should be transferred
5; even if it is on only one of the regions.
6
7; This includes the attributes no-jump-tables, profile-sample-accurate,
8; speculative_load_hardening, and noimplicitfloat.  When instance of similarity
9; has these attributes can we say that the outlined function can have these
10; attributes since that is the more general case.
11
12define void @outline_attrs1() #0 {
13; CHECK-LABEL: @outline_attrs1(
14; CHECK-NEXT:  entry:
15; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 4
16; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 4
17; CHECK-NEXT:    [[C:%.*]] = alloca i32, align 4
18; CHECK-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]])
19; CHECK-NEXT:    ret void
20;
21entry:
22  %a = alloca i32, align 4
23  %b = alloca i32, align 4
24  %c = alloca i32, align 4
25  store i32 2, ptr %a, align 4
26  store i32 3, ptr %b, align 4
27  store i32 4, ptr %c, align 4
28  %al = load i32, ptr %a
29  %bl = load i32, ptr %b
30  %cl = load i32, ptr %c
31  ret void
32}
33
34define void @outline_attrs2() {
35; CHECK-LABEL: @outline_attrs2(
36; CHECK-NEXT:  entry:
37; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 4
38; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 4
39; CHECK-NEXT:    [[C:%.*]] = alloca i32, align 4
40; CHECK-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[C]])
41; CHECK-NEXT:    ret void
42;
43entry:
44  %a = alloca i32, align 4
45  %b = alloca i32, align 4
46  %c = alloca i32, align 4
47  store i32 2, ptr %a, align 4
48  store i32 3, ptr %b, align 4
49  store i32 4, ptr %c, align 4
50  %al = load i32, ptr %a
51  %bl = load i32, ptr %b
52  %cl = load i32, ptr %c
53  ret void
54}
55
56attributes #0 = { "no-jump-tables"="true" "profile-sample-accurate"="true" "speculative_load_hardening" "noimplicitfloat"="true" "use-sample-profile"="true"}
57
58; CHECK: define internal void @outlined_ir_func_0(ptr [[ARG0:%.*]], ptr [[ARG1:%.*]], ptr [[ARG2:%.*]]) [[ATTR:#[0-9]+]] {
59; CHECK: entry_to_outline:
60; CHECK-NEXT:    store i32 2, ptr [[ARG0]], align 4
61; CHECK-NEXT:    store i32 3, ptr [[ARG1]], align 4
62; CHECK-NEXT:    store i32 4, ptr [[ARG2]], align 4
63; CHECK-NEXT:    [[AL:%.*]] = load i32, ptr [[ARG0]], align 4
64; CHECK-NEXT:    [[BL:%.*]] = load i32, ptr [[ARG1]], align 4
65; CHECK-NEXT:    [[CL:%.*]] = load i32, ptr [[ARG2]], align 4
66
67; CHECK: attributes [[ATTR]] = { minsize optsize "no-jump-tables"="true" "noimplicitfloat"="true" "profile-sample-accurate"="true" "speculative_load_hardening" "use-sample-profile"="true" }
68