[PATCH] D126565: [RegisterClassInfo] Invalidate cached information if ignoreCSRForAllocationOrder changes
Srividya Karumuri via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 27 14:02:44 PDT 2022
Srividya-Karumuri created this revision.
Srividya-Karumuri added a reviewer: qcolombet.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Srividya-Karumuri requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126565
Files:
llvm/include/llvm/CodeGen/RegisterClassInfo.h
llvm/lib/CodeGen/RegisterClassInfo.cpp
Index: llvm/lib/CodeGen/RegisterClassInfo.cpp
===================================================================
--- llvm/lib/CodeGen/RegisterClassInfo.cpp
+++ llvm/lib/CodeGen/RegisterClassInfo.cpp
@@ -43,9 +43,11 @@
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 @@
}
CalleeSavedRegs = CSR;
+ // Even if CSR list is same, we could have had a different allocation order
+ // if ignoreCSRForAllocationOrder is evaluated differently.
+ 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?
Index: llvm/include/llvm/CodeGen/RegisterClassInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/RegisterClassInfo.h
+++ llvm/include/llvm/CodeGen/RegisterClassInfo.h
@@ -60,6 +60,10 @@
// 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126565.432631.patch
Type: text/x-patch
Size: 1947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220527/24893019/attachment.bin>
More information about the llvm-commits
mailing list