[PATCH] D98232: WIP - don't submit (yet)
Mircea Trofin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 8 20:56:25 PST 2021
mtrofin created this revision.
Herald added subscribers: hiraditya, qcolombet, MatzeB.
mtrofin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98232
Files:
llvm/include/llvm/CodeGen/LiveIntervalUnion.h
llvm/lib/CodeGen/LiveIntervalUnion.cpp
llvm/lib/CodeGen/RegAllocGreedy.cpp
Index: llvm/lib/CodeGen/RegAllocGreedy.cpp
===================================================================
--- llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -987,7 +987,7 @@
for (MCRegUnitIterator Units(PhysReg, TRI); Units.isValid(); ++Units) {
LiveIntervalUnion::Query &Q = Matrix->query(VirtReg, *Units);
-
+ Q.collectInterferingVRegs();
// Check if any interfering live range is heavier than MaxWeight.
for (const LiveInterval *Intf : reverse(Q.interferingVRegs())) {
// Check if interference overlast the segment in interest.
Index: llvm/lib/CodeGen/LiveIntervalUnion.cpp
===================================================================
--- llvm/lib/CodeGen/LiveIntervalUnion.cpp
+++ llvm/lib/CodeGen/LiveIntervalUnion.cpp
@@ -112,7 +112,7 @@
// Scan the vector of interfering virtual registers in this union. Assume it's
// quite small.
bool LiveIntervalUnion::Query::isSeenInterference(LiveInterval *VirtReg) const {
- return is_contained(InterferingVRegs, VirtReg);
+ return is_contained(*InterferingVRegs, VirtReg);
}
// Collect virtual registers in this union that interfere with this
@@ -126,9 +126,12 @@
//
unsigned LiveIntervalUnion::Query::
collectInterferingVRegs(unsigned MaxInterferingRegs) {
+ if (!InterferingVRegs)
+ InterferingVRegs.emplace();
+
// Fast path return if we already have the desired information.
- if (SeenAllInterferences || InterferingVRegs.size() >= MaxInterferingRegs)
- return InterferingVRegs.size();
+ if (SeenAllInterferences || InterferingVRegs->size() >= MaxInterferingRegs)
+ return InterferingVRegs->size();
// Set up iterators on the first call.
if (!CheckedFirstInterference) {
@@ -157,14 +160,14 @@
LiveInterval *VReg = LiveUnionI.value();
if (VReg != RecentReg && !isSeenInterference(VReg)) {
RecentReg = VReg;
- InterferingVRegs.push_back(VReg);
- if (InterferingVRegs.size() >= MaxInterferingRegs)
- return InterferingVRegs.size();
+ InterferingVRegs->push_back(VReg);
+ if (InterferingVRegs->size() >= MaxInterferingRegs)
+ return InterferingVRegs->size();
}
// This LiveUnion segment is no longer interesting.
if (!(++LiveUnionI).valid()) {
SeenAllInterferences = true;
- return InterferingVRegs.size();
+ return InterferingVRegs->size();
}
}
@@ -185,7 +188,7 @@
LiveUnionI.advanceTo(LRI->start);
}
SeenAllInterferences = true;
- return InterferingVRegs.size();
+ return InterferingVRegs->size();
}
void LiveIntervalUnion::Array::init(LiveIntervalUnion::Allocator &Alloc,
Index: llvm/include/llvm/CodeGen/LiveIntervalUnion.h
===================================================================
--- llvm/include/llvm/CodeGen/LiveIntervalUnion.h
+++ llvm/include/llvm/CodeGen/LiveIntervalUnion.h
@@ -114,7 +114,7 @@
const LiveRange *LR = nullptr;
LiveRange::const_iterator LRI; ///< current position in LR
ConstSegmentIter LiveUnionI; ///< current position in LiveUnion
- SmallVector<LiveInterval*,4> InterferingVRegs;
+ Optional<SmallVector<LiveInterval *, 4>> InterferingVRegs;
bool CheckedFirstInterference = false;
bool SeenAllInterferences = false;
unsigned Tag = 0;
@@ -124,7 +124,7 @@
const LiveIntervalUnion &NewLiveUnion) {
LiveUnion = &NewLiveUnion;
LR = &NewLR;
- InterferingVRegs.clear();
+ InterferingVRegs = None;
CheckedFirstInterference = false;
SeenAllInterferences = false;
Tag = NewLiveUnion.getTag();
@@ -164,7 +164,7 @@
// Vector generated by collectInterferingVRegs.
const SmallVectorImpl<LiveInterval*> &interferingVRegs() const {
- return InterferingVRegs;
+ return *InterferingVRegs;
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98232.329200.patch
Type: text/x-patch
Size: 3848 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210309/76019b9e/attachment.bin>
More information about the llvm-commits
mailing list