226 lines · plain
1# RUN: llc %s -run-pass=machine-sink --aarch64-enable-sink-fold=true -o - | FileCheck %s2 3# RUN: llc %s -passes="machine-sink<enable-sink-fold>" -o - | FileCheck %s4--- |5 target triple = "aarch64-linux"6 7 @.str = private unnamed_addr constant [12 x i8] c"result: %d\0A\00", align 1, !dbg !08 9 define i32 @foo(i32 %x, i32 %y) !dbg !18 {10 entry:11 %add = add i32 %x, 3, !dbg !2512 %add1 = add i32 %add, %y, !dbg !2613 ret i32 %add1, !dbg !2714 }15 16 define i32 @baz(i32 %y) !dbg !28 {17 entry:18 %add1.i = add i32 %y, 23, !dbg !3419 tail call void @bar(ptr nonnull @.str, i32 %add1.i), !dbg !3620 ret i32 0, !dbg !3721 }22 23 declare !dbg !38 void @bar(ptr noundef, i32 noundef)24 25 !llvm.dbg.cu = !{!7}26 !llvm.module.flags = !{!9, !10, !11, !12, !13, !14, !15, !16}27 !llvm.ident = !{!17}28 29 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())30 !1 = distinct !DIGlobalVariable(scope: null, file: !2, line: 9, type: !3, isLocal: true, isDefinition: true)31 !2 = !DIFile(filename: "m.c", directory: "/home/chill")32 !3 = !DICompositeType(tag: DW_TAG_array_type, baseType: !4, size: 96, elements: !5)33 !4 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned_char)34 !5 = !{!6}35 !6 = !DISubrange(count: 12)36 !7 = distinct !DICompileUnit(language: DW_LANG_C11, file: !2, producer: "clang version 18.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false, nameTableKind: None)37 !8 = !{!0}38 !9 = !{i32 7, !"Dwarf Version", i32 5}39 !10 = !{i32 2, !"Debug Info Version", i32 3}40 !11 = !{i32 1, !"wchar_size", i32 4}41 !12 = !{i32 8, !"PIC Level", i32 2}42 !13 = !{i32 7, !"PIE Level", i32 2}43 !14 = !{i32 7, !"uwtable", i32 2}44 !15 = !{i32 7, !"frame-pointer", i32 1}45 !16 = !{i32 7, !"debug-info-assignment-tracking", i1 true}46 !17 = !{!"clang version 18.0.0"}47 !18 = distinct !DISubprogram(name: "foo", scope: !2, file: !2, line: 1, type: !19, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !7, retainedNodes: !22)48 !19 = !DISubroutineType(types: !20)49 !20 = !{!21, !21, !21}50 !21 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)51 !22 = !{!23, !24}52 !23 = !DILocalVariable(name: "x", arg: 1, scope: !18, file: !2, line: 1, type: !21)53 !24 = !DILocalVariable(name: "y", arg: 2, scope: !18, file: !2, line: 1, type: !21)54 !25 = !DILocation(line: 2, column: 12, scope: !18)55 !26 = !DILocation(line: 2, column: 16, scope: !18)56 !27 = !DILocation(line: 2, column: 3, scope: !18)57 !28 = distinct !DISubprogram(name: "baz", scope: !2, file: !2, line: 7, type: !29, scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !7, retainedNodes: !31)58 !29 = !DISubroutineType(types: !30)59 !30 = !{!21, !21}60 !31 = !{!32, !33}61 !32 = !DILocalVariable(name: "y", arg: 1, scope: !28, file: !2, line: 7, type: !21)62 !33 = !DILocalVariable(name: "result", scope: !28, file: !2, line: 8, type: !21)63 !34 = !DILocation(line: 2, column: 16, scope: !18, inlinedAt: !35)64 !35 = distinct !DILocation(line: 8, column: 16, scope: !28)65 !36 = !DILocation(line: 9, column: 3, scope: !28)66 !37 = !DILocation(line: 10, column: 3, scope: !28)67 !38 = !DISubprogram(name: "bar", scope: !2, file: !2, line: 5, type: !39, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)68 !39 = !DISubroutineType(types: !40)69 !40 = !{null, !41, !21}70 !41 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !42, size: 64)71 !42 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !4)72 73...74---75name: foo76alignment: 477exposesReturnsTwice: false78legalized: false79regBankSelected: false80selected: false81failedISel: false82tracksRegLiveness: true83hasWinCFI: false84callsEHReturn: false85callsUnwindInit: false86hasEHContTarget: false87hasEHScopes: false88hasEHFunclets: false89isOutlined: false90debugInstrRef: false91failsVerification: false92tracksDebugUserValues: false93registers:94 - { id: 0, class: gpr32, preferred-register: '' }95 - { id: 1, class: gpr32, preferred-register: '' }96 - { id: 2, class: gpr32common, preferred-register: '' }97 - { id: 3, class: gpr32sp, preferred-register: '' }98liveins:99 - { reg: '$w0', virtual-reg: '%0' }100 - { reg: '$w1', virtual-reg: '%1' }101frameInfo:102 isFrameAddressTaken: false103 isReturnAddressTaken: false104 hasStackMap: false105 hasPatchPoint: false106 stackSize: 0107 offsetAdjustment: 0108 maxAlignment: 1109 adjustsStack: false110 hasCalls: false111 stackProtector: ''112 functionContext: ''113 maxCallFrameSize: 0114 cvBytesOfCalleeSavedRegisters: 0115 hasOpaqueSPAdjustment: false116 hasVAStart: false117 hasMustTailInVarArgFunc: false118 hasTailCall: false119 localFrameSize: 0120 savePoint: []121 restorePoint: []122fixedStack: []123stack: []124entry_values: []125callSites: []126debugValueSubstitutions: []127constants: []128machineFunctionInfo: {}129body: |130 bb.0.entry:131 liveins: $w0, $w1132 133 ; CHECK-LABEL: name: foo134 135 ; Check the source location of the ADDWri was reused (usually the136 ; copy to $w0 carries the same debug location as the return)137 138 ; CHECK: $w0 = ADDWri {{.*}}, 3, 0, debug-location !26139 ; CHECK-NEXT: RET_ReallyLR implicit $w0, debug-location !27140 %1:gpr32 = COPY $w1141 %0:gpr32 = COPY $w0142 %2:gpr32common = ADDWrr %0, %1, debug-location !25143 $w0 = ADDWri %2, 3, 0, debug-location !26144 RET_ReallyLR implicit $w0, debug-location !27145 146...147---148name: baz149alignment: 4150exposesReturnsTwice: false151legalized: false152regBankSelected: false153selected: false154failedISel: false155tracksRegLiveness: true156hasWinCFI: false157callsEHReturn: false158callsUnwindInit: false159hasEHContTarget: false160hasEHScopes: false161hasEHFunclets: false162isOutlined: false163debugInstrRef: false164failsVerification: false165tracksDebugUserValues: false166registers:167 - { id: 0, class: gpr32common, preferred-register: '' }168 - { id: 1, class: gpr32sp, preferred-register: '' }169 - { id: 2, class: gpr64common, preferred-register: '' }170 - { id: 3, class: gpr32all, preferred-register: '' }171liveins:172 - { reg: '$w0', virtual-reg: '%0' }173frameInfo:174 isFrameAddressTaken: false175 isReturnAddressTaken: false176 hasStackMap: false177 hasPatchPoint: false178 stackSize: 0179 offsetAdjustment: 0180 maxAlignment: 1181 adjustsStack: true182 hasCalls: true183 stackProtector: ''184 functionContext: ''185 maxCallFrameSize: 0186 cvBytesOfCalleeSavedRegisters: 0187 hasOpaqueSPAdjustment: false188 hasVAStart: false189 hasMustTailInVarArgFunc: false190 hasTailCall: false191 localFrameSize: 0192 savePoint: []193 restorePoint: []194fixedStack: []195stack: []196entry_values: []197callSites: []198debugValueSubstitutions: []199constants: []200machineFunctionInfo: {}201body: |202 bb.0.entry:203 liveins: $w0204 205 ; CHECK-LABEL: name: baz206 207 ; Check the source location of the ADDWri was reused (usually the208 ; copy to $w1 carries the same debug location as the BL)209 210 ; CHECK: $x0 = COPY {{.*}}, debug-location !36211 ; CHECK-NEXT: $w1 = ADDWri {{.*}}, 23, 0, debug-location !34212 ; CHECK-NEXT: BL @bar, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit $w1, implicit-def $sp, debug-location !36213 214 %0:gpr32common = COPY $w0215 ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp, debug-location !36216 %2:gpr64common = MOVaddr target-flags(aarch64-page) @.str, target-flags(aarch64-pageoff, aarch64-nc) @.str, debug-location !36217 $x0 = COPY %2, debug-location !36218 $w1 = ADDWri %0, 23, 0, debug-location !34219 BL @bar, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit $w1, implicit-def $sp, debug-location !36220 ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp, debug-location !36221 %3:gpr32all = COPY $wzr222 $w0 = COPY %3, debug-location !37223 RET_ReallyLR implicit $w0, debug-location !37224 225...226