[PATCH] D110834: [PHIElimination] Account for INLINEASM_BR when inserting kills
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 1 11:44:31 PDT 2021
foad updated this revision to Diff 376588.
foad added a comment.
Rebase on a test case that I will pre-commit.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110834/new/
https://reviews.llvm.org/D110834
Files:
llvm/lib/CodeGen/PHIElimination.cpp
llvm/test/CodeGen/X86/callbr-asm-kill.ll
Index: llvm/test/CodeGen/X86/callbr-asm-kill.ll
===================================================================
--- llvm/test/CodeGen/X86/callbr-asm-kill.ll
+++ llvm/test/CodeGen/X86/callbr-asm-kill.ll
@@ -3,8 +3,9 @@
declare void @foo(i8*)
-; FIXME: The COPY from [[MOV64rm]] should not be killed, because there is a
-; subsequent use of [[MOV64rm]] in the INLINEASM_BR instruction.
+; Check that the COPY from [[MOV64rm]] is not killed, because there is a
+; subsequent use of [[MOV64rm]] in the INLINEASM_BR instruction which should be
+; killed instead.
define void @test1(i8* %arg, i8** %mem) nounwind {
; CHECK-LABEL: name: test1
; CHECK: bb.0.entry:
@@ -24,8 +25,8 @@
; CHECK-NEXT: $rdi = COPY killed [[COPY3]]
; CHECK-NEXT: CALL64pcrel32 target-flags(x86-plt) @foo, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit-def $rsp, implicit-def $ssp
; CHECK-NEXT: ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
- ; CHECK-NEXT: [[COPY4:%[0-9]+]]:gr64 = COPY killed [[MOV64rm]]
- ; CHECK-NEXT: INLINEASM_BR &"", 9 /* sideeffect mayload attdialect */, 196654 /* mem:m */, [[MOV64rm]], 1, $noreg, 0, $noreg, 13 /* imm */, blockaddress(@test1, %ir-block.loop)
+ ; CHECK-NEXT: [[COPY4:%[0-9]+]]:gr64 = COPY [[MOV64rm]]
+ ; CHECK-NEXT: INLINEASM_BR &"", 9 /* sideeffect mayload attdialect */, 196654 /* mem:m */, killed [[MOV64rm]], 1, $noreg, 0, $noreg, 13 /* imm */, blockaddress(@test1, %ir-block.loop)
; CHECK-NEXT: JMP_1 %bb.2
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.2.end:
Index: llvm/lib/CodeGen/PHIElimination.cpp
===================================================================
--- llvm/lib/CodeGen/PHIElimination.cpp
+++ llvm/lib/CodeGen/PHIElimination.cpp
@@ -515,9 +515,8 @@
// case, we should mark the last such terminator as being the killing
// block, not the copy.
MachineBasicBlock::iterator KillInst = opBlock.end();
- MachineBasicBlock::iterator FirstTerm = opBlock.getFirstTerminator();
- for (MachineBasicBlock::iterator Term = FirstTerm;
- Term != opBlock.end(); ++Term) {
+ for (MachineBasicBlock::iterator Term = InsertPos; Term != opBlock.end();
+ ++Term) {
if (Term->readsRegister(SrcReg))
KillInst = Term;
}
@@ -527,7 +526,7 @@
if (reusedIncoming || !IncomingReg) {
// We may have to rewind a bit if we didn't insert a copy this time.
- KillInst = FirstTerm;
+ KillInst = InsertPos;
while (KillInst != opBlock.begin()) {
--KillInst;
if (KillInst->isDebugInstr())
@@ -574,9 +573,8 @@
if (!isLiveOut) {
MachineBasicBlock::iterator KillInst = opBlock.end();
- MachineBasicBlock::iterator FirstTerm = opBlock.getFirstTerminator();
- for (MachineBasicBlock::iterator Term = FirstTerm;
- Term != opBlock.end(); ++Term) {
+ for (MachineBasicBlock::iterator Term = InsertPos;
+ Term != opBlock.end(); ++Term) {
if (Term->readsRegister(SrcReg))
KillInst = Term;
}
@@ -586,7 +584,7 @@
if (reusedIncoming || !IncomingReg) {
// We may have to rewind a bit if we didn't just insert a copy.
- KillInst = FirstTerm;
+ KillInst = InsertPos;
while (KillInst != opBlock.begin()) {
--KillInst;
if (KillInst->isDebugInstr())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110834.376588.patch
Type: text/x-patch
Size: 3561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211001/dd9aa437/attachment.bin>
More information about the llvm-commits
mailing list