[llvm] [AArch64] Resolve FIXME: Use scavengeRegisterBackwards to find the best unused register (PR #78910)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 7 06:35:50 PST 2024
https://github.com/AtariDreams updated https://github.com/llvm/llvm-project/pull/78910
>From 09cc32de86588f47b51eae7db76f740a2699531c Mon Sep 17 00:00:00 2001
From: Rose <83477269+AtariDreams at users.noreply.github.com>
Date: Sun, 21 Jan 2024 14:53:16 -0500
Subject: [PATCH] [AArch64] Resolve FIXME: Use RegScavenger to find the best
unused register
---
.../Target/AArch64/AArch64SpeculationHardening.cpp | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/llvm/lib/Target/AArch64/AArch64SpeculationHardening.cpp b/llvm/lib/Target/AArch64/AArch64SpeculationHardening.cpp
index a991d645eb6f40..a65b41f6c74d75 100644
--- a/llvm/lib/Target/AArch64/AArch64SpeculationHardening.cpp
+++ b/llvm/lib/Target/AArch64/AArch64SpeculationHardening.cpp
@@ -296,17 +296,9 @@ bool AArch64SpeculationHardening::instrumentControlFlow(
// The RegScavenger represents registers available *after* the MI
// instruction pointed to by RS.getCurrentPosition().
// We need to have a register that is available *before* the MI is executed.
- if (I == MBB.begin())
- RS.enterBasicBlock(MBB);
- else
- RS.backward(I);
- // FIXME: The below just finds *a* unused register. Maybe code could be
- // optimized more if this looks for the register that isn't used for the
- // longest time around this place, to enable more scheduling freedom. Not
- // sure if that would actually result in a big performance difference
- // though. Maybe RegisterScavenger::findSurvivorBackwards has some logic
- // already to do this - but it's unclear if that could easily be used here.
- Register TmpReg = RS.FindUnusedReg(&AArch64::GPR64commonRegClass);
+ RS.backward(I);
+ Register TmpReg = RS.scavengeRegisterBackwards(AArch64::GPR64commonRegClass,
+ I, false, 0, false);
LLVM_DEBUG(dbgs() << "RS finds "
<< ((TmpReg == 0) ? "no register " : "register ");
if (TmpReg != 0) dbgs() << printReg(TmpReg, TRI) << " ";
More information about the llvm-commits
mailing list