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