1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs -O2 -run-pass=livevars,phi-node-elimination -o - %s | FileCheck %s
3 # RUN: llc -mtriple=x86_64-unknown-linux-gnu -O2 --passes='require<live-vars>,phi-node-elimination' -o - %s | FileCheck %s
5 # Check that the COPY from [[MOV64rm]] is not killed, because there is a
6 # subsequent use of [[MOV64rm]] in the INLINEASM_BR instruction which should be
10 source_filename = "<stdin>"
11 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
12 target triple = "x86_64-unknown-linux-gnu"
14 declare void @foo(ptr)
16 ; Function Attrs: nounwind
17 define void @test1(ptr %arg, ptr %mem) #0 {
21 loop: ; preds = %loop, %entry
22 %a = phi ptr [ %arg, %entry ], [ %b, %loop ]
23 %b = load ptr, ptr %mem, align 8
24 call void @foo(ptr %a)
25 callbr void asm sideeffect "", "*m,!i"(ptr elementtype(i8) %b)
26 to label %end [label %loop]
32 attributes #0 = { nounwind }
38 tracksRegLiveness: true
40 - { id: 0, class: gr64 }
41 - { id: 1, class: gr64 }
42 - { id: 2, class: gr64 }
43 - { id: 3, class: gr64 }
45 - { reg: '$rdi', virtual-reg: '%2' }
46 - { reg: '$rsi', virtual-reg: '%3' }
51 machineFunctionInfo: {}
53 ; CHECK-LABEL: name: test1
55 ; CHECK-NEXT: successors: %bb.1(0x80000000)
56 ; CHECK-NEXT: liveins: $rdi, $rsi
58 ; CHECK-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY killed $rsi
59 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr64 = COPY killed $rdi
60 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:gr64 = COPY killed [[COPY1]]
62 ; CHECK-NEXT: bb.1.loop (ir-block-address-taken %ir-block.loop, inlineasm-br-indirect-target):
63 ; CHECK-NEXT: successors: %bb.2(0x80000000), %bb.1(0x00000000)
65 ; CHECK-NEXT: [[COPY3:%[0-9]+]]:gr64 = COPY killed [[COPY2]]
66 ; CHECK-NEXT: [[MOV64rm:%[0-9]+]]:gr64 = MOV64rm [[COPY]], 1, $noreg, 0, $noreg :: (load (s64) from %ir.mem)
67 ; CHECK-NEXT: ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
68 ; CHECK-NEXT: $rdi = COPY killed [[COPY3]]
69 ; CHECK-NEXT: CALL64pcrel32 target-flags(x86-plt) @foo, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit-def $rsp, implicit-def $ssp
70 ; CHECK-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
71 ; CHECK-NEXT: [[COPY4:%[0-9]+]]:gr64 = COPY [[MOV64rm]]
72 ; CHECK-NEXT: INLINEASM_BR &"", 9 /* sideeffect mayload attdialect */, 262190 /* mem:m */, killed [[MOV64rm]], 1, $noreg, 0, $noreg, 13 /* imm */, blockaddress(@test1, %ir-block.loop)
73 ; CHECK-NEXT: JMP_1 %bb.2
75 ; CHECK-NEXT: bb.2.end:
80 %3:gr64 = COPY killed $rsi
81 %2:gr64 = COPY killed $rdi
83 bb.1.loop (ir-block-address-taken %ir-block.loop, inlineasm-br-indirect-target):
84 successors: %bb.2(0x80000000), %bb.1(0x00000000)
86 %0:gr64 = PHI %2, %bb.0, %1, %bb.1
87 %1:gr64 = MOV64rm %3, 1, $noreg, 0, $noreg :: (load (s64) from %ir.mem)
88 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
90 CALL64pcrel32 target-flags(x86-plt) @foo, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit-def $rsp, implicit-def $ssp
91 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
92 INLINEASM_BR &"", 9 /* sideeffect mayload attdialect */, 262190 /* mem:m */, %1, 1, $noreg, 0, $noreg, 13 /* imm */, blockaddress(@test1, %ir-block.loop)