1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
2 # RUN: llc --aarch64-enable-sink-fold=true --run-pass=machine-sink %s -o - | FileCheck %s
4 source_filename = "x.ll"
5 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
6 target triple = "aarch64-linux"
8 %S = type <{ ptr, %T, i64, i64, i32, [4 x i8] }>
9 %T = type { ptr, ptr, ptr, ptr, i64 }
11 define void @f(ptr %p, i1 %c0, i1 %c1) {
13 %a = getelementptr %S, ptr %p, i64 0, i32 1
14 call void @llvm.dbg.value(metadata ptr %a, metadata !4, metadata !DIExpression()), !dbg !10
15 br i1 %c0, label %if.then, label %if.end
17 if.then: ; preds = %entry
18 %v0 = tail call ptr @g(ptr %a)
19 br i1 %c1, label %exit, label %if.end
21 if.end: ; preds = %if.then, %entry
22 %v1 = load i64, ptr %a, align 8
25 exit: ; preds = %if.end, %if.then
40 declare void @llvm.dbg.value(metadata, metadata, metadata) #0
42 attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
45 !llvm.module.flags = !{!2, !3}
47 !0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
48 !1 = !DIFile(filename: "f.c", directory: "/usr/rms")
49 !2 = !{i32 7, !"Dwarf Version", i32 4}
50 !3 = !{i32 2, !"Debug Info Version", i32 3}
51 !4 = !DILocalVariable(name: "x", arg: 1, scope: !5, file: !1, line: 2, type: !8)
52 !5 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !6, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !9)
53 !6 = !DISubroutineType(types: !7)
55 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
57 !10 = !DILocation(line: 2, column: 11, scope: !5)
63 exposesReturnsTwice: false
65 regBankSelected: false
68 tracksRegLiveness: true
71 callsUnwindInit: false
77 failsVerification: false
78 tracksDebugUserValues: false
80 - { id: 0, class: gpr64all, preferred-register: '' }
81 - { id: 1, class: gpr64common, preferred-register: '' }
82 - { id: 2, class: gpr32, preferred-register: '' }
83 - { id: 3, class: gpr32, preferred-register: '' }
84 - { id: 4, class: gpr32, preferred-register: '' }
85 - { id: 5, class: gpr64sp, preferred-register: '' }
86 - { id: 6, class: gpr64all, preferred-register: '' }
88 - { reg: '$x0', virtual-reg: '%1' }
89 - { reg: '$w1', virtual-reg: '%2' }
90 - { reg: '$w2', virtual-reg: '%3' }
92 isFrameAddressTaken: false
93 isReturnAddressTaken: false
104 cvBytesOfCalleeSavedRegisters: 0
105 hasOpaqueSPAdjustment: false
107 hasMustTailInVarArgFunc: false
116 debugValueSubstitutions: []
118 machineFunctionInfo: {}
120 ; CHECK-LABEL: name: f
122 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
123 ; CHECK-NEXT: liveins: $x0, $w1, $w2
125 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32 = COPY $w2
126 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY $w1
127 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr64common = COPY $x0
128 ; CHECK-NEXT: DBG_VALUE $noreg, $noreg, !4, !DIExpression(), debug-location !10
129 ; CHECK-NEXT: TBZW [[COPY1]], 0, %bb.2
130 ; CHECK-NEXT: B %bb.1
132 ; CHECK-NEXT: bb.1.if.then:
133 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
135 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gpr32 = COPY [[COPY]]
136 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
137 ; CHECK-NEXT: $x0 = ADDXri [[COPY2]], 8, 0
138 ; CHECK-NEXT: DBG_VALUE $x0, $noreg, !4, !DIExpression(), debug-location !10
139 ; CHECK-NEXT: BL @g, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit-def $sp, implicit-def $x0
140 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
141 ; CHECK-NEXT: TBNZW [[COPY3]], 0, %bb.3
142 ; CHECK-NEXT: B %bb.2
144 ; CHECK-NEXT: bb.2.if.end:
145 ; CHECK-NEXT: successors: %bb.3(0x80000000)
148 ; CHECK-NEXT: bb.3.exit:
149 ; CHECK-NEXT: RET_ReallyLR
151 successors: %bb.1(0x40000000), %bb.2(0x40000000)
152 liveins: $x0, $w1, $w2
156 %1:gpr64common = COPY $x0
158 %5:gpr64sp = ADDXri %1, 8, 0
159 DBG_VALUE %5, $noreg, !4, !DIExpression(), debug-location !10
160 %0:gpr64all = COPY %5
165 successors: %bb.3(0x40000000), %bb.2(0x40000000)
167 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
169 BL @g, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit-def $sp, implicit-def $x0
170 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
175 successors: %bb.3(0x80000000)
185 exposesReturnsTwice: false
187 regBankSelected: false
190 tracksRegLiveness: true
193 callsUnwindInit: false
199 failsVerification: false
200 tracksDebugUserValues: false
202 - { id: 0, class: gpr64all, preferred-register: '' }
203 - { id: 1, class: gpr64common, preferred-register: '' }
204 - { id: 2, class: gpr32, preferred-register: '' }
205 - { id: 3, class: gpr32, preferred-register: '' }
206 - { id: 4, class: gpr32, preferred-register: '' }
207 - { id: 5, class: gpr64sp, preferred-register: '' }
208 - { id: 6, class: gpr64all, preferred-register: '' }
210 - { reg: '$x0', virtual-reg: '%1' }
211 - { reg: '$w1', virtual-reg: '%2' }
212 - { reg: '$w2', virtual-reg: '%3' }
214 isFrameAddressTaken: false
215 isReturnAddressTaken: false
226 cvBytesOfCalleeSavedRegisters: 0
227 hasOpaqueSPAdjustment: false
229 hasMustTailInVarArgFunc: false
238 debugValueSubstitutions: []
240 machineFunctionInfo: {}
242 ; CHECK-LABEL: name: g
244 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
245 ; CHECK-NEXT: liveins: $x0, $w1, $w2
247 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr32 = COPY $w2
248 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr32 = COPY $w1
249 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr64common = COPY $x0
250 ; CHECK-NEXT: DBG_VALUE_LIST !4, !DIExpression(), [[COPY]], $noreg, debug-location !10
251 ; CHECK-NEXT: TBZW [[COPY1]], 0, %bb.2
252 ; CHECK-NEXT: B %bb.1
254 ; CHECK-NEXT: bb.1.if.then:
255 ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
257 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gpr32 = COPY [[COPY]]
258 ; CHECK-NEXT: DBG_VALUE_LIST !4, !DIExpression(), [[COPY3]], $noreg, debug-location !10
259 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
260 ; CHECK-NEXT: $x0 = ADDXri [[COPY2]], 8, 0
261 ; CHECK-NEXT: DBG_VALUE_LIST !4, !DIExpression(), [[COPY3]], $x0, debug-location !10
262 ; CHECK-NEXT: BL @g, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit-def $sp, implicit-def $x0
263 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
264 ; CHECK-NEXT: TBNZW [[COPY3]], 0, %bb.3
265 ; CHECK-NEXT: B %bb.2
267 ; CHECK-NEXT: bb.2.if.end:
268 ; CHECK-NEXT: successors: %bb.3(0x80000000)
271 ; CHECK-NEXT: bb.3.exit:
272 ; CHECK-NEXT: RET_ReallyLR
274 successors: %bb.1(0x40000000), %bb.2(0x40000000)
275 liveins: $x0, $w1, $w2
279 %1:gpr64common = COPY $x0
281 %5:gpr64sp = ADDXri %1, 8, 0
282 DBG_VALUE_LIST !4, !DIExpression(), %4:gpr32, %5:gpr64sp, debug-location !10
283 %0:gpr64all = COPY %5
288 successors: %bb.3(0x40000000), %bb.2(0x40000000)
290 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp
292 BL @g, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit-def $sp, implicit-def $x0
293 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp
298 successors: %bb.3(0x80000000)