[PATCH] D128804: [greedyalloc] Return early when there is no register to allocate.
LuoYuanke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 29 18:34:51 PDT 2022
LuoYuanke updated this revision to Diff 441224.
LuoYuanke added a comment.
Address Xiang's comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128804/new/
https://reviews.llvm.org/D128804
Files:
llvm/lib/CodeGen/RegAllocGreedy.cpp
llvm/lib/CodeGen/RegAllocGreedy.h
Index: llvm/lib/CodeGen/RegAllocGreedy.h
===================================================================
--- llvm/lib/CodeGen/RegAllocGreedy.h
+++ llvm/lib/CodeGen/RegAllocGreedy.h
@@ -315,6 +315,7 @@
void enqueue(PQueue &CurQueue, const LiveInterval *LI);
const LiveInterval *dequeue(PQueue &CurQueue);
+ bool hasVirtRegAlloc();
BlockFrequency calcSpillCost();
bool addSplitConstraints(InterferenceCache::Cursor, BlockFrequency &);
bool addThroughConstraints(InterferenceCache::Cursor, ArrayRef<unsigned>);
Index: llvm/lib/CodeGen/RegAllocGreedy.cpp
===================================================================
--- llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -2488,6 +2488,21 @@
}
}
+bool RAGreedy::hasVirtRegAlloc() {
+ for (unsigned I = 0, E = MRI->getNumVirtRegs(); I != E; ++I) {
+ Register Reg = Register::index2VirtReg(I);
+ if (MRI->reg_nodbg_empty(Reg))
+ continue;
+ const TargetRegisterClass *RC = MRI->getRegClass(Reg);
+ if (!RC)
+ continue;
+ if (ShouldAllocateClass(*TRI, *RC))
+ return true;
+ }
+
+ return false;
+}
+
bool RAGreedy::runOnMachineFunction(MachineFunction &mf) {
LLVM_DEBUG(dbgs() << "********** GREEDY REGISTER ALLOCATION **********\n"
<< "********** Function: " << mf.getName() << '\n');
@@ -2501,6 +2516,12 @@
RegAllocBase::init(getAnalysis<VirtRegMap>(),
getAnalysis<LiveIntervals>(),
getAnalysis<LiveRegMatrix>());
+
+ // Early return if there is no virtual register to be allocated to a
+ // physical register.
+ if (!hasVirtRegAlloc())
+ return false;
+
Indexes = &getAnalysis<SlotIndexes>();
MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
DomTree = &getAnalysis<MachineDominatorTree>();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128804.441224.patch
Type: text/x-patch
Size: 1819 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220630/8a8bf6ae/attachment.bin>
More information about the llvm-commits
mailing list