Skip to content

Commit cad5328

Browse files
committed
[X86] Add late tail duplication tests with computed gotos.
Add a new test for post-regalloc tail duplication with computed gotos to complement llvm/test/CodeGen/X86/tail-dup-computed-goto.mir.
1 parent 525090e commit cad5328

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2+
# RUN: llc -mtriple=x86_64-unknown-linux-gnu -run-pass=tailduplication -tail-dup-pred-size=1 -tail-dup-succ-size=1 %s -o - | FileCheck %s
3+
#
4+
# Check that only the computed gotos are duplicated aggressively.
5+
#
6+
--- |
7+
@computed_goto.dispatch = constant [5 x ptr] [ptr null, ptr blockaddress(@computed_goto, %bb1), ptr blockaddress(@computed_goto, %bb2), ptr blockaddress(@computed_goto, %bb3), ptr blockaddress(@computed_goto, %bb4)]
8+
declare i64 @f0()
9+
declare i64 @f1()
10+
declare i64 @f2()
11+
declare i64 @f3()
12+
declare i64 @f4()
13+
declare i64 @f5()
14+
define void @computed_goto() {
15+
start:
16+
ret void
17+
bb1:
18+
ret void
19+
bb2:
20+
ret void
21+
bb3:
22+
ret void
23+
bb4:
24+
ret void
25+
}
26+
define void @jump_table() { ret void }
27+
define void @jump_table_pic() { ret void }
28+
...
29+
---
30+
name: computed_goto
31+
alignment: 1
32+
exposesReturnsTwice: false
33+
legalized: false
34+
regBankSelected: false
35+
selected: false
36+
failedISel: false
37+
tracksRegLiveness: true
38+
body: |
39+
; CHECK-LABEL: name: computed_goto
40+
; CHECK: bb.0:
41+
; CHECK-NEXT: successors: %bb.1(0x20000000), %bb.2(0x20000000), %bb.3(0x20000000), %bb.4(0x20000000)
42+
; CHECK-NEXT: {{ $}}
43+
; CHECK-NEXT: CALL64pcrel32 target-flags(x86-plt) @f0, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $rax
44+
; CHECK-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY $rax
45+
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr64_nosp = COPY [[COPY]]
46+
; CHECK-NEXT: [[COPY2:%[0-9]+]]:gr64_nosp = COPY [[COPY1]]
47+
; CHECK-NEXT: JMP64m $noreg, 8, [[COPY2]], @computed_goto.dispatch, $noreg
48+
; CHECK-NEXT: {{ $}}
49+
; CHECK-NEXT: bb.1.bb1 (ir-block-address-taken %ir-block.bb1):
50+
; CHECK-NEXT: successors: %bb.1(0x20000000), %bb.2(0x20000000), %bb.3(0x20000000), %bb.4(0x20000000)
51+
; CHECK-NEXT: {{ $}}
52+
; CHECK-NEXT: CALL64pcrel32 target-flags(x86-plt) @f1, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $rax
53+
; CHECK-NEXT: [[COPY3:%[0-9]+]]:gr64 = COPY $rax
54+
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr64_nosp = COPY [[COPY3]]
55+
; CHECK-NEXT: [[COPY2:%[0-9]+]]:gr64_nosp = COPY [[COPY1]]
56+
; CHECK-NEXT: JMP64m $noreg, 8, [[COPY2]], @computed_goto.dispatch, $noreg
57+
; CHECK-NEXT: {{ $}}
58+
; CHECK-NEXT: bb.2.bb2 (ir-block-address-taken %ir-block.bb2):
59+
; CHECK-NEXT: successors: %bb.1(0x20000000), %bb.2(0x20000000), %bb.3(0x20000000), %bb.4(0x20000000)
60+
; CHECK-NEXT: {{ $}}
61+
; CHECK-NEXT: CALL64pcrel32 target-flags(x86-plt) @f2, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $rax
62+
; CHECK-NEXT: [[COPY4:%[0-9]+]]:gr64 = COPY $rax
63+
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr64_nosp = COPY [[COPY4]]
64+
; CHECK-NEXT: [[COPY2:%[0-9]+]]:gr64_nosp = COPY [[COPY1]]
65+
; CHECK-NEXT: JMP64m $noreg, 8, [[COPY2]], @computed_goto.dispatch, $noreg
66+
; CHECK-NEXT: {{ $}}
67+
; CHECK-NEXT: bb.3.bb3 (ir-block-address-taken %ir-block.bb3):
68+
; CHECK-NEXT: successors: %bb.1(0x20000000), %bb.2(0x20000000), %bb.3(0x20000000), %bb.4(0x20000000)
69+
; CHECK-NEXT: {{ $}}
70+
; CHECK-NEXT: CALL64pcrel32 target-flags(x86-plt) @f3, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $rax
71+
; CHECK-NEXT: [[COPY5:%[0-9]+]]:gr64 = COPY $rax
72+
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr64_nosp = COPY [[COPY5]]
73+
; CHECK-NEXT: [[COPY2:%[0-9]+]]:gr64_nosp = COPY [[COPY1]]
74+
; CHECK-NEXT: JMP64m $noreg, 8, [[COPY2]], @computed_goto.dispatch, $noreg
75+
; CHECK-NEXT: {{ $}}
76+
; CHECK-NEXT: bb.4.bb4 (ir-block-address-taken %ir-block.bb4):
77+
; CHECK-NEXT: successors: %bb.1(0x20000000), %bb.2(0x20000000), %bb.3(0x20000000), %bb.4(0x20000000)
78+
; CHECK-NEXT: {{ $}}
79+
; CHECK-NEXT: CALL64pcrel32 target-flags(x86-plt) @f4, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $rax
80+
; CHECK-NEXT: [[COPY6:%[0-9]+]]:gr64 = COPY $rax
81+
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr64_nosp = COPY [[COPY6]]
82+
; CHECK-NEXT: [[COPY2:%[0-9]+]]:gr64_nosp = COPY [[COPY1]]
83+
; CHECK-NEXT: JMP64m $noreg, 8, [[COPY2]], @computed_goto.dispatch, $noreg
84+
bb.0:
85+
successors: %bb.5(0x80000000)
86+
87+
CALL64pcrel32 target-flags(x86-plt) @f0, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $rax
88+
%0:gr64 = COPY $rax
89+
%6:gr64_nosp = COPY %0
90+
JMP_1 %bb.5
91+
92+
bb.1.bb1 (ir-block-address-taken %ir-block.bb1):
93+
successors: %bb.5(0x80000000)
94+
95+
CALL64pcrel32 target-flags(x86-plt) @f1, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $rax
96+
%1:gr64 = COPY $rax
97+
%6:gr64_nosp = COPY %1
98+
JMP_1 %bb.5
99+
100+
bb.2.bb2 (ir-block-address-taken %ir-block.bb2):
101+
successors: %bb.5(0x80000000)
102+
103+
CALL64pcrel32 target-flags(x86-plt) @f2, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $rax
104+
%2:gr64 = COPY $rax
105+
%6:gr64_nosp = COPY %2
106+
JMP_1 %bb.5
107+
108+
bb.3.bb3 (ir-block-address-taken %ir-block.bb3):
109+
successors: %bb.5(0x80000000)
110+
111+
CALL64pcrel32 target-flags(x86-plt) @f3, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $rax
112+
%3:gr64 = COPY $rax
113+
%6:gr64_nosp = COPY %3
114+
JMP_1 %bb.5
115+
116+
bb.4.bb4 (ir-block-address-taken %ir-block.bb4):
117+
successors: %bb.5(0x80000000)
118+
119+
CALL64pcrel32 target-flags(x86-plt) @f4, csr_64, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp, implicit-def $rax
120+
%4:gr64 = COPY $rax
121+
%6:gr64_nosp = COPY %4
122+
123+
bb.5:
124+
successors: %bb.1(0x20000000), %bb.2(0x20000000), %bb.3(0x20000000), %bb.4(0x20000000)
125+
126+
%5:gr64_nosp = COPY %6
127+
JMP64m $noreg, 8, %5, @computed_goto.dispatch, $noreg
128+
...

0 commit comments

Comments
 (0)