[llvm] 1a155ee - [RegisterClassInfo] Invalidate cached information if ignoreCSRForAllocationOrder changes
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 1 17:16:03 PDT 2022
Author: Quentin Colombet
Date: 2022-06-01T17:15:51-07:00
New Revision: 1a155ee7de3b62a2fabee86fb470a1554fadc54d
URL: https://github.com/llvm/llvm-project/commit/1a155ee7de3b62a2fabee86fb470a1554fadc54d
DIFF: https://github.com/llvm/llvm-project/commit/1a155ee7de3b62a2fabee86fb470a1554fadc54d.diff
LOG: [RegisterClassInfo] Invalidate cached information if ignoreCSRForAllocationOrder changes
Even if CSR list is same between functions, we could have had a different
allocation order if ignoreCSRForAllocationOrder is evaluated differently.
Hence invalidate cached register class information if
ignoreCSRForAllocationOrder changes.
Patch by Srividya Karumuri <srividya_karumuri at apple.com>
Differential Revision: https://reviews.llvm.org/D126565
Added:
Modified:
llvm/include/llvm/CodeGen/RegisterClassInfo.h
llvm/lib/CodeGen/RegisterClassInfo.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/RegisterClassInfo.h b/llvm/include/llvm/CodeGen/RegisterClassInfo.h
index d97a5dba547c..39c72a42c433 100644
--- a/llvm/include/llvm/CodeGen/RegisterClassInfo.h
+++ b/llvm/include/llvm/CodeGen/RegisterClassInfo.h
@@ -60,6 +60,10 @@ class RegisterClassInfo {
// Map register alias to the callee saved Register.
SmallVector<MCPhysReg, 4> CalleeSavedAliases;
+ // Indicate if a specified callee saved register be in the allocation order
+ // exactly as written in the tablegen descriptions or listed later.
+ BitVector IgnoreCSRForAllocOrder;
+
// Reserved registers in the current MF.
BitVector Reserved;
diff --git a/llvm/lib/CodeGen/RegisterClassInfo.cpp b/llvm/lib/CodeGen/RegisterClassInfo.cpp
index bb97c2d7273a..374fcc9a6014 100644
--- a/llvm/lib/CodeGen/RegisterClassInfo.cpp
+++ b/llvm/lib/CodeGen/RegisterClassInfo.cpp
@@ -43,9 +43,11 @@ void RegisterClassInfo::runOnMachineFunction(const MachineFunction &mf) {
bool Update = false;
MF = &mf;
+ auto &STI = MF->getSubtarget();
+
// Allocate new array the first time we see a new target.
- if (MF->getSubtarget().getRegisterInfo() != TRI) {
- TRI = MF->getSubtarget().getRegisterInfo();
+ if (STI.getRegisterInfo() != TRI) {
+ TRI = STI.getRegisterInfo();
RegClass.reset(new RCInfo[TRI->getNumRegClasses()]);
Update = true;
}
@@ -67,6 +69,18 @@ void RegisterClassInfo::runOnMachineFunction(const MachineFunction &mf) {
}
CalleeSavedRegs = CSR;
+ // Even if CSR list is same, we could have had a
diff erent allocation order
+ // if ignoreCSRForAllocationOrder is evaluated
diff erently.
+ BitVector CSRHintsForAllocOrder(TRI->getNumRegs());
+ for (const MCPhysReg *I = CSR; *I; ++I)
+ for (MCRegAliasIterator AI(*I, TRI, true); AI.isValid(); ++AI)
+ CSRHintsForAllocOrder[*AI] = STI.ignoreCSRForAllocationOrder(mf, *AI);
+ if (IgnoreCSRForAllocOrder.size() != CSRHintsForAllocOrder.size() ||
+ IgnoreCSRForAllocOrder != CSRHintsForAllocOrder) {
+ Update = true;
+ IgnoreCSRForAllocOrder = CSRHintsForAllocOrder;
+ }
+
RegCosts = TRI->getRegisterCosts(*MF);
// Different reserved registers?
More information about the llvm-commits
mailing list