1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --include-generated-funcs
2; RUN: llc -enable-machine-outliner -mtriple=x86_64-unknown-linux < %s | FileCheck %s
3@x = dso_local global i32 0, align 4
4
5define dso_local i32 @check_boundaries() #0 {
6  %1 = alloca i32, align 4
7  %2 = alloca i32, align 4
8  %3 = alloca i32, align 4
9  %4 = alloca i32, align 4
10  %5 = alloca i32, align 4
11  store i32 0, i32* %1, align 4
12  store i32 0, i32* %2, align 4
13  %6 = load i32, i32* %2, align 4
14  %7 = icmp ne i32 %6, 0
15  br i1 %7, label %9, label %8
16
17  store i32 1, i32* %2, align 4
18  store i32 2, i32* %3, align 4
19  store i32 3, i32* %4, align 4
20  store i32 4, i32* %5, align 4
21  br label %10
22
23  store i32 1, i32* %4, align 4
24  br label %10
25
26  %11 = load i32, i32* %2, align 4
27  %12 = icmp ne i32 %11, 0
28  br i1 %12, label %14, label %13
29
30  store i32 1, i32* %2, align 4
31  store i32 2, i32* %3, align 4
32  store i32 3, i32* %4, align 4
33  store i32 4, i32* %5, align 4
34  br label %15
35
36  store i32 1, i32* %4, align 4
37  br label %15
38
39  ret i32 0
40}
41
42define dso_local i32 @main() #0 {
43  %1 = alloca i32, align 4
44  %2 = alloca i32, align 4
45  %3 = alloca i32, align 4
46  %4 = alloca i32, align 4
47  %5 = alloca i32, align 4
48
49  store i32 0, i32* %1, align 4
50  store i32 0, i32* @x, align 4
51  store i32 1, i32* %2, align 4
52  store i32 2, i32* %3, align 4
53  store i32 3, i32* %4, align 4
54  store i32 4, i32* %5, align 4
55  store i32 1, i32* @x, align 4
56  call void asm sideeffect "", "~{memory},~{dirflag},~{fpsr},~{flags}"()
57  store i32 1, i32* %2, align 4
58  store i32 2, i32* %3, align 4
59  store i32 3, i32* %4, align 4
60  store i32 4, i32* %5, align 4
61  ret i32 0
62}
63
64attributes #0 = { noredzone nounwind ssp uwtable "frame-pointer"="all" }
65; CHECK-LABEL: check_boundaries:
66; CHECK:       # %bb.0:
67; CHECK-NEXT:    pushq %rbp
68; CHECK-NEXT:    .cfi_def_cfa_offset 16
69; CHECK-NEXT:    .cfi_offset %rbp, -16
70; CHECK-NEXT:    movq %rsp, %rbp
71; CHECK-NEXT:    .cfi_def_cfa_register %rbp
72; CHECK-NEXT:    subq $20, %rsp
73; CHECK-NEXT:    movl $0, -20(%rbp)
74; CHECK-NEXT:    movl $0, -8(%rbp)
75; CHECK-NEXT:    xorl %eax, %eax
76; CHECK-NEXT:    testb %al, %al
77; CHECK-NEXT:    je .LBB0_1
78; CHECK-NEXT:  # %bb.2:
79; CHECK-NEXT:    movl $1, -4(%rbp)
80; CHECK-NEXT:    cmpl $0, -8(%rbp)
81; CHECK-NEXT:    je .LBB0_4
82; CHECK-NEXT:  .LBB0_5:
83; CHECK-NEXT:    movl $1, -4(%rbp)
84; CHECK-NEXT:    jmp .LBB0_6
85; CHECK-NEXT:  .LBB0_1:
86; CHECK-NEXT:    callq OUTLINED_FUNCTION_0
87; CHECK-NEXT:    cmpl $0, -8(%rbp)
88; CHECK-NEXT:    jne .LBB0_5
89; CHECK-NEXT:  .LBB0_4:
90; CHECK-NEXT:    callq OUTLINED_FUNCTION_0
91; CHECK-NEXT:  .LBB0_6:
92; CHECK-NEXT:    xorl %eax, %eax
93; CHECK-NEXT:    addq $20, %rsp
94; CHECK-NEXT:    popq %rbp
95; CHECK-NEXT:    .cfi_def_cfa %rsp, 8
96; CHECK-NEXT:    retq
97;
98; CHECK-LABEL: main:
99; CHECK:       # %bb.0:
100; CHECK-NEXT:    pushq %rbp
101; CHECK-NEXT:    .cfi_def_cfa_offset 16
102; CHECK-NEXT:    .cfi_offset %rbp, -16
103; CHECK-NEXT:    movq %rsp, %rbp
104; CHECK-NEXT:    .cfi_def_cfa_register %rbp
105; CHECK-NEXT:    subq $20, %rsp
106; CHECK-NEXT:    movl $0, -20(%rbp)
107; CHECK-NEXT:    callq OUTLINED_FUNCTION_1
108; CHECK-NEXT:    movl $1, x(%rip)
109; CHECK-NEXT:    #APP
110; CHECK-NEXT:    #NO_APP
111; CHECK-NEXT:    callq OUTLINED_FUNCTION_1
112; CHECK-NEXT:    xorl %eax, %eax
113; CHECK-NEXT:    addq $20, %rsp
114; CHECK-NEXT:    popq %rbp
115; CHECK-NEXT:    .cfi_def_cfa %rsp, 8
116; CHECK-NEXT:    retq
117;
118; CHECK-LABEL: OUTLINED_FUNCTION_0:
119; CHECK:       # %bb.0:
120; CHECK-NEXT:    movl $1, -8(%rbp)
121; CHECK-NEXT:    movl $2, -16(%rbp)
122; CHECK-NEXT:    movl $3, -4(%rbp)
123; CHECK-NEXT:    movl $4, -12(%rbp)
124; CHECK-NEXT:    retq
125;
126; CHECK-LABEL: OUTLINED_FUNCTION_1:
127; CHECK:       # %bb.0:
128; CHECK-NEXT:    movl $1, -16(%rbp)
129; CHECK-NEXT:    movl $2, -12(%rbp)
130; CHECK-NEXT:    movl $3, -8(%rbp)
131; CHECK-NEXT:    movl $4, -4(%rbp)
132; CHECK-NEXT:    retq
133