1# RUN: llc -run-pass=tailduplication -tail-dup-size=4 %s -o - | FileCheck %s 2# RUN: llc -passes=tailduplication -tail-dup-size=4 %s -o - | FileCheck %s 3 4# JumpTableDest32 uses an `adr` to a temporary label (itself). If duplicated we 5# cannot guarantee reachability for any uses after the first. 6 7# CHECK: JumpTableDest32 8# CHECK-NOT: JumpTableDest32 9 10 11--- | 12 ; ModuleID = 'jump-table.ll' 13 source_filename = "jump-table.ll" 14 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128" 15 target triple = "arm64-apple-ios" 16 17 define i32 @test_jumptable32(i32 %in, i1 %tst) { 18 br i1 %tst, label %true, label %false 19 20 true: ; preds = %0 21 call void @foo() 22 br label %switch 23 24 false: ; preds = %0 25 call void @bar() 26 br label %switch 27 28 lbl1: ; preds = %lbl4, %lbl3, %def, %switch 29 %merge = phi i32 [ 1, %switch ], [ 0, %def ], [ 4, %lbl3 ], [ 8, %lbl4 ] 30 ret i32 %merge 31 32 switch: ; preds = %false, %true 33 switch i32 %in, label %def [ 34 i32 0, label %lbl1 35 i32 1, label %lbl2 36 i32 2, label %lbl3 37 i32 4, label %lbl4 38 ] 39 40 def: ; preds = %switch 41 br label %lbl1 42 43 lbl2: ; preds = %switch 44 %1 = call i64 @llvm.aarch64.space(i32 262144, i64 undef) 45 ret i32 2 46 47 lbl3: ; preds = %switch 48 br label %lbl1 49 50 lbl4: ; preds = %switch 51 br label %lbl1 52 } 53 54 declare void @foo() 55 56 declare void @bar() 57 58 ; Function Attrs: nounwind 59 declare i64 @llvm.aarch64.space(i32, i64) #0 60 61 attributes #0 = { nounwind } 62 63... 64--- 65name: test_jumptable32 66alignment: 4 67exposesReturnsTwice: false 68legalized: false 69regBankSelected: false 70selected: false 71failedISel: false 72tracksRegLiveness: true 73hasWinCFI: false 74registers: [] 75liveins: 76 - { reg: '$w0', virtual-reg: '' } 77 - { reg: '$w1', virtual-reg: '' } 78frameInfo: 79 isFrameAddressTaken: false 80 isReturnAddressTaken: false 81 hasStackMap: false 82 hasPatchPoint: false 83 stackSize: 32 84 offsetAdjustment: 0 85 maxAlignment: 8 86 adjustsStack: true 87 hasCalls: true 88 stackProtector: '' 89 maxCallFrameSize: 0 90 cvBytesOfCalleeSavedRegisters: 0 91 hasOpaqueSPAdjustment: false 92 hasVAStart: false 93 hasMustTailInVarArgFunc: false 94 localFrameSize: 0 95 savePoint: '' 96 restorePoint: '' 97fixedStack: [] 98stack: 99 - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, 100 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true, 101 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } 102 - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, 103 stack-id: default, callee-saved-register: '$fp', callee-saved-restored: true, 104 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } 105 - { id: 2, name: '', type: spill-slot, offset: -24, size: 8, alignment: 8, 106 stack-id: default, callee-saved-register: '$x19', callee-saved-restored: true, 107 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } 108 - { id: 3, name: '', type: spill-slot, offset: -32, size: 8, alignment: 8, 109 stack-id: default, callee-saved-register: '$x20', callee-saved-restored: true, 110 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } 111callSites: [] 112constants: [] 113machineFunctionInfo: 114 hasRedZone: false 115jumpTable: 116 kind: label-difference32 117 entries: 118 - id: 0 119 blocks: [ '%bb.9', '%bb.6', '%bb.7', '%bb.5', '%bb.8' ] 120body: | 121 bb.0 (%ir-block.0): 122 successors: %bb.1(0x40000000), %bb.2(0x40000000) 123 liveins: $w0, $w1, $x19, $x20, $lr 124 125 early-clobber $sp = frame-setup STPXpre killed $x20, killed $x19, $sp, -4 :: (store (s64) into %stack.3), (store (s64) into %stack.2) 126 frame-setup STPXi killed $fp, killed $lr, $sp, 2 :: (store (s64) into %stack.1), (store (s64) into %stack.0) 127 frame-setup CFI_INSTRUCTION def_cfa_offset 32 128 frame-setup CFI_INSTRUCTION offset $w30, -8 129 frame-setup CFI_INSTRUCTION offset $w29, -16 130 frame-setup CFI_INSTRUCTION offset $w19, -24 131 frame-setup CFI_INSTRUCTION offset $w20, -32 132 renamable $w19 = COPY $w0 133 TBZW killed renamable $w1, 0, %bb.2 134 135 bb.1.true: 136 successors: %bb.3(0x80000000) 137 liveins: $w19 138 139 BL @foo, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp 140 B %bb.3 141 142 bb.2.false: 143 successors: %bb.3(0x80000000) 144 liveins: $w19 145 146 BL @bar, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp 147 B %bb.3 148 149 bb.3.switch: 150 successors: %bb.9(0x1c71c71c), %bb.6(0x1c71c71c), %bb.7(0x1c71c71c), %bb.5(0x0e38e38e), %bb.8(0x1c71c71c) 151 liveins: $w19 152 153 renamable $w8 = ORRWrs $wzr, killed renamable $w19, 0, implicit-def $x8 154 renamable $x9 = MOVaddrJT target-flags(aarch64-page) %jump-table.0, target-flags(aarch64-pageoff, aarch64-nc) %jump-table.0 155 early-clobber renamable $x10, dead early-clobber renamable $x11 = JumpTableDest32 killed renamable $x9, killed renamable $x8, %jump-table.0 156 BR killed renamable $x10 157 158 bb.5.def: 159 successors: %bb.9(0x80000000) 160 161 renamable $w0 = COPY $wzr 162 B %bb.9 163 164 bb.6.lbl2: 165 successors: %bb.9(0x80000000) 166 167 dead $xzr = SPACE 262144, undef renamable $x8 168 $w0 = MOVi32imm 2 169 B %bb.9 170 171 bb.7.lbl3: 172 successors: %bb.9(0x80000000) 173 174 renamable $w0 = MOVi32imm 4 175 B %bb.9 176 177 bb.8.lbl4: 178 successors: %bb.9(0x80000000) 179 180 renamable $w0 = MOVi32imm 8 181 182 bb.9.lbl1: 183 liveins: $w0 184 185 $fp, $lr = frame-destroy LDPXi $sp, 2 :: (load (s64) from %stack.1), (load (s64) from %stack.0) 186 early-clobber $sp, $x20, $x19 = frame-destroy LDPXpost $sp, 4 :: (load (s64) from %stack.3), (load (s64) from %stack.2) 187 RET_ReallyLR implicit $w0 188 189... 190