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