1 # RUN: llc -mtriple=aarch64--- -run-pass=prologepilog -run-pass=machine-outliner -verify-machineinstrs %s -o - | FileCheck %s
4 @x = common global i32 0, align 4
6 define void @baz() #0 {
10 define i32 @main() #0 {
14 define void @bar(i32 %a) #0 {
18 attributes #0 = { noinline noredzone "no-frame-pointer-elim"="true" }
21 # This test ensures that we
22 # - Create outlined functions
23 # - Don't outline anything to do with LR or W30
24 # - Save LR when it's not available
25 # - Functions whose addresses are taken can still be outlined
29 # CHECK-DAG: BL @OUTLINED_FUNCTION_[[F0:[0-9]+]]
30 # CHECK-NEXT: $lr = ORRXrs $xzr, $x[[REG:[0-9]+]], 0
31 # CHECK-NEXT: STRHHroW $w12, $x9, $w30, 1, 1
32 # CHECK-NEXT: $lr = ORRXri $xzr, 1
35 # CHECK: BL @OUTLINED_FUNCTION_[[F0]]
36 # CHECK-NEXT: $lr = ORRXrs $xzr, $x[[REG]], 0
37 # CHECK-NEXT: STRHHroW $w12, $x9, $w30, 1, 1
38 # CHECK-NEXT: $lr = ORRXri $xzr, 1
41 # CHECK: BL @OUTLINED_FUNCTION_[[F0]]
42 # CHECK-NEXT: $lr = ORRXrs $xzr, $x[[REG]], 0
43 # CHECK-NEXT: STRHHroW $w12, $x9, $w30, 1, 1
44 # CHECK-NEXT: $lr = ORRXri $xzr, 1
46 tracksRegLiveness: true
50 $sp = frame-setup SUBXri $sp, 16, 0
51 renamable $x9 = ADRP target-flags(aarch64-page) @bar
58 $x20, $x19 = LDPXi $sp, 10
65 renamable $x9 = ADRP target-flags(aarch64-page) @x
66 $x12 = ADDXri $sp, 48, 0;
67 STRHHroW $w12, $x9, $w30, 1, 1
71 $x20, $x19 = LDPXi $sp, 10
78 renamable $x9 = ADRP target-flags(aarch64-page) @x
79 $x12 = ADDXri $sp, 48, 0;
80 STRHHroW $w12, $x9, $w30, 1, 1
84 $x20, $x19 = LDPXi $sp, 10
91 renamable $x9 = ADRP target-flags(aarch64-page) @x
92 $x12 = ADDXri $sp, 48, 0;
93 STRHHroW $w12, $x9, $w30, 1, 1
95 $sp = ADDXri $sp, 16, 0
102 # This test ensures that we can avoid saving LR when it's available.
103 # It also makes sure that KILL instructions don't impact outlining.
105 # CHECK-NOT: BL @baz, implicit-def dead $lr, implicit $sp
106 # CHECK: BL @OUTLINED_FUNCTION_[[F1:[0-9]+]], implicit-def $lr, implicit $sp
107 # CHECK-NEXT: $w11 = ORRWri $wzr, 2
108 # CHECK-NEXT: BL @OUTLINED_FUNCTION_[[F1]], implicit-def $lr, implicit $sp
109 # CHECK-NEXT: $w8 = ORRWri $wzr, 0
110 # CHECK-NOT: $w11 = KILL renamable $w11, implicit killed $w11
112 tracksRegLiveness: true
115 liveins: $w0, $lr, $w8
116 $sp = frame-setup SUBXri $sp, 32, 0
117 $fp = frame-setup ADDXri $sp, 16, 0
120 BL @baz, implicit-def dead $lr, implicit $sp
121 $w11 = ORRWri $wzr, 1
122 $w11 = ORRWri $wzr, 1
123 $w11 = KILL renamable $w11, implicit killed $w11
124 $w11 = ORRWri $wzr, 1
125 $w11 = ORRWri $wzr, 1
126 BL @baz, implicit-def dead $lr, implicit $sp
127 $w11 = ORRWri $wzr, 1
128 $w11 = ORRWri $wzr, 1
129 $w11 = ORRWri $wzr, 2
130 BL @baz, implicit-def dead $lr, implicit $sp
131 $w11 = ORRWri $wzr, 1
132 $w11 = ORRWri $wzr, 1
133 $w11 = ORRWri $wzr, 1
134 $w11 = ORRWri $wzr, 1
135 BL @baz, implicit-def dead $lr, implicit $sp
136 $w11 = ORRWri $wzr, 1
137 $w11 = ORRWri $wzr, 1
141 $w15 = ORRWri $wzr, 1
142 $w15 = ORRWri $wzr, 1
143 $w15 = ORRWri $wzr, 1
144 $w15 = ORRWri $wzr, 1
145 $x15 = ADDXri $sp, 48, 0;
147 $w15 = ORRWri $wzr, 1
148 $w15 = ORRWri $wzr, 1
149 $w15 = ORRWri $wzr, 1
150 $w15 = ORRWri $wzr, 1
151 $x15 = ADDXri $sp, 48, 0;
155 $fp, $lr = LDPXi $sp, 2
156 $sp = ADDXri $sp, 32, 0
162 tracksRegLiveness: true
165 liveins: $w0, $lr, $w8
168 # CHECK-LABEL: name: OUTLINED_FUNCTION_{{[0-9]}}
169 # CHECK=LABEL: name: OUTLINED_FUNCTION_{{[1-9]}}