2016-07-16 10:24:59 +08:00
|
|
|
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
|
2015-07-29 01:28:03 +08:00
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
2015-08-07 07:57:04 +08:00
|
|
|
define void @slot_in_other_function(i8** %addr) {
|
|
|
|
entry:
|
|
|
|
store volatile i8* blockaddress(@test3, %0), i8** %addr
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2015-07-29 01:28:03 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2015-08-06 06:26:15 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2015-07-29 01:28:03 +08:00
|
|
|
...
|
|
|
|
---
|
|
|
|
name: test
|
2015-08-14 07:10:16 +08:00
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
successors: %bb.1.block
|
|
|
|
; CHECK: %rax = LEA64r %rip, 1, _, blockaddress(@test, %ir-block.block), _
|
|
|
|
%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
|
2015-07-29 01:28:03 +08:00
|
|
|
...
|
|
|
|
---
|
|
|
|
name: test2
|
|
|
|
tracksRegLiveness: true
|
2015-08-14 07:10:16 +08:00
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
successors: %bb.1
|
|
|
|
; CHECK: %rax = LEA64r %rip, 1, _, blockaddress(@test2, %ir-block."quoted block"), _
|
|
|
|
%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
|
2015-07-29 01:28:03 +08:00
|
|
|
...
|
|
|
|
---
|
2015-08-07 07:57:04 +08:00
|
|
|
name: slot_in_other_function
|
|
|
|
tracksRegLiveness: true
|
2015-08-14 07:10:16 +08:00
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
liveins: %rdi
|
|
|
|
; CHECK-LABEL: name: slot_in_other_function
|
|
|
|
; CHECK: %rax = LEA64r %rip, 1, _, blockaddress(@test3, %ir-block.0), _
|
|
|
|
%rax = LEA64r %rip, 1, _, blockaddress(@test3, %ir-block.0), _
|
|
|
|
MOV64mr killed %rdi, 1, _, 0, _, killed %rax
|
|
|
|
RETQ
|
2015-08-07 07:57:04 +08:00
|
|
|
...
|
|
|
|
---
|
2015-07-29 01:28:03 +08:00
|
|
|
name: test3
|
|
|
|
tracksRegLiveness: true
|
2015-08-14 07:10:16 +08:00
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
successors: %bb.1
|
|
|
|
; CHECK-LABEL: name: test3
|
|
|
|
; CHECK: %rax = LEA64r %rip, 1, _, blockaddress(@test3, %ir-block.0), _
|
|
|
|
%rax = LEA64r %rip, 1, _, blockaddress(@test3, %ir-block.0), _
|
|
|
|
MOV64mr %rip, 1, _, @addr, _, killed %rax
|
|
|
|
JMP64m %rip, 1, _, @addr, _
|
|
|
|
|
|
|
|
bb.1 (address-taken):
|
|
|
|
RETQ
|
2015-07-29 01:28:03 +08:00
|
|
|
...
|
2015-08-06 06:26:15 +08:00
|
|
|
---
|
|
|
|
name: test4
|
2015-08-14 07:10:16 +08:00
|
|
|
body: |
|
|
|
|
bb.0.entry:
|
|
|
|
successors: %bb.1.block
|
|
|
|
; CHECK: %rax = LEA64r %rip, 1, _, blockaddress(@test, %ir-block.block) + 2, _
|
|
|
|
%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
|
2015-08-06 06:26:15 +08:00
|
|
|
...
|