[llvm] [X86] Resolve FIXME: Copy kill flag (PR #82411)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 20 11:56:37 PST 2024
https://github.com/AtariDreams created https://github.com/llvm/llvm-project/pull/82411
We now mark the last eflags usage as kill if the def was also kill.
>From 57e3df6028e971e230d3b848819e7bf8ec913145 Mon Sep 17 00:00:00 2001
From: Rose <83477269+AtariDreams at users.noreply.github.com>
Date: Tue, 20 Feb 2024 14:29:42 -0500
Subject: [PATCH] Resolve FIXME: Copy kill flag
We now mark the last eflags usage as kill if the def was also kill.
---
llvm/lib/Target/X86/X86FlagsCopyLowering.cpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp b/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp
index af25b34fbab995..e9830f086668a0 100644
--- a/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp
+++ b/llvm/lib/Target/X86/X86FlagsCopyLowering.cpp
@@ -683,6 +683,8 @@ bool X86FlagsCopyLoweringPass::runOnMachineFunction(MachineFunction &MF) {
// Now rewrite the jumps that use the flags. These we handle specially
// because if there are multiple jumps in a single basic block we'll have
// to do surgery on the CFG.
+ bool CopyDefIsKill = CopyDefI.killsRegister(X86::EFLAGS);
+ MachineOperand *LastEflagsUse = nullptr;
MachineBasicBlock *LastJmpMBB = nullptr;
for (MachineInstr *JmpI : JmpIs) {
// Past the first jump within a basic block we need to split the blocks
@@ -693,10 +695,13 @@ bool X86FlagsCopyLoweringPass::runOnMachineFunction(MachineFunction &MF) {
LastJmpMBB = JmpI->getParent();
rewriteCondJmp(*TestMBB, TestPos, TestLoc, *JmpI, CondRegs);
+ if (JmpI->readsRegister(X86::EFLAGS))
+ LastEflagsUse = JmpI->findRegisterUseOperand(X86::EFLAGS);
}
- // FIXME: Mark the last use of EFLAGS before the copy's def as a kill if
- // the copy's def operand is itself a kill.
+ // After the loop that processes jumps:
+ if (LastEflagsUse && CopyDefIsKill)
+ LastEflagsUse->setIsKill(true);
}
#ifndef NDEBUG
More information about the llvm-commits
mailing list