1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
| # RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses the block address operands
# correctly.
--- |
@addr = global i8* null
define void @test() {
entry:
store volatile i8* blockaddress(@test, %block), i8** @addr
%val = load volatile i8*, i8** @addr
indirectbr i8* %val, [label %block]
block:
ret void
}
define void @test2() {
entry:
store volatile i8* blockaddress(@test2, %"quoted block"), i8** @addr
%val = load volatile i8*, i8** @addr
indirectbr i8* %val, [label %"quoted block"]
"quoted block":
ret void
}
define void @slot_in_other_function(i8** %addr) {
entry:
store volatile i8* blockaddress(@test3, %0), i8** %addr
ret void
}
define void @test3() {
entry:
store volatile i8* blockaddress(@test3, %0), i8** @addr
%val = load volatile i8*, i8** @addr
indirectbr i8* %val, [label %0]
ret void
}
define void @test4() {
entry:
store volatile i8* blockaddress(@test4, %block), i8** @addr
%val = load volatile i8*, i8** @addr
indirectbr i8* %val, [label %block]
block:
ret void
}
...
---
name: test
body: |
bb.0.entry:
successors: %bb.1.block
; CHECK: $rax = LEA64r $rip, 1, $noreg, blockaddress(@test, %ir-block.block), $noreg
$rax = LEA64r $rip, 1, _, blockaddress(@test, %ir-block.block), _
MOV64mr $rip, 1, _, @addr, _, killed $rax
JMP64m $rip, 1, _, @addr, _
bb.1.block (address-taken):
RETQ
...
---
name: test2
tracksRegLiveness: true
body: |
bb.0.entry:
successors: %bb.1
; CHECK: $rax = LEA64r $rip, 1, $noreg, blockaddress(@test2, %ir-block."quoted block"), $noreg
$rax = LEA64r $rip, 1, _, blockaddress(@test2, %ir-block."quoted block"), _
MOV64mr $rip, 1, _, @addr, _, killed $rax
JMP64m $rip, 1, _, @addr, _
bb.1 (address-taken):
RETQ
...
---
name: slot_in_other_function
tracksRegLiveness: true
body: |
bb.0.entry:
liveins: $rdi
; CHECK-LABEL: name: slot_in_other_function
; CHECK: $rax = LEA64r $rip, 1, $noreg, blockaddress(@test3, %ir-block.0), $noreg
$rax = LEA64r $rip, 1, _, blockaddress(@test3, %ir-block.0), _
MOV64mr killed $rdi, 1, _, 0, _, killed $rax
RETQ
...
---
name: test3
tracksRegLiveness: true
body: |
bb.0.entry:
successors: %bb.1
; CHECK-LABEL: name: test3
; CHECK: $rax = LEA64r $rip, 1, $noreg, blockaddress(@test3, %ir-block.0), $noreg
$rax = LEA64r $rip, 1, _, blockaddress(@test3, %ir-block.0), _
MOV64mr $rip, 1, _, @addr, _, killed $rax
JMP64m $rip, 1, _, @addr, _
bb.1 (address-taken):
RETQ
...
---
name: test4
body: |
bb.0.entry:
successors: %bb.1.block
; CHECK: $rax = LEA64r $rip, 1, $noreg, blockaddress(@test, %ir-block.block) + 2, $noreg
$rax = LEA64r $rip, 1, _, blockaddress(@test, %ir-block.block) + 2, _
MOV64mr $rip, 1, _, @addr, _, killed $rax
JMP64m $rip, 1, _, @addr, _
bb.1.block (address-taken):
RETQ
...
|