aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Foad <jay.foad@amd.com>2024-02-13 16:04:41 +0000
committerJay Foad <jay.foad@amd.com>2024-02-13 16:08:56 +0000
commit1f90af183d7a007584fac041eaca9f126a1a942f (patch)
treeaefd4bc53ba10372beb189493b044fe067b99468
parent11fcae69dbea4860e20ab799ecca9b0432d7f19d (diff)
downloadllvm-1f90af183d7a007584fac041eaca9f126a1a942f.zip
llvm-1f90af183d7a007584fac041eaca9f126a1a942f.tar.gz
llvm-1f90af183d7a007584fac041eaca9f126a1a942f.tar.bz2
[TableGen] Do not speculatively grow RegUnitSets. NFC.
This seems to be a trick to avoid copying a RegUnitSet, but it can be done more simply using std::move.
-rw-r--r--llvm/utils/TableGen/CodeGenRegisters.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/llvm/utils/TableGen/CodeGenRegisters.cpp b/llvm/utils/TableGen/CodeGenRegisters.cpp
index dd18507..0b67127 100644
--- a/llvm/utils/TableGen/CodeGenRegisters.cpp
+++ b/llvm/utils/TableGen/CodeGenRegisters.cpp
@@ -1985,18 +1985,14 @@ void CodeGenRegBank::computeRegUnitSets() {
if (!RC.Allocatable || RC.Artificial || !RC.GeneratePressureSet)
continue;
- // Speculatively grow the RegUnitSets to hold the new set.
- RegUnitSet &RUSet = RegUnitSets.emplace_back();
- RUSet.Name = RC.getName();
-
// Compute a sorted list of units in this class.
+ RegUnitSet RUSet;
+ RUSet.Name = RC.getName();
RC.buildRegUnitSet(*this, RUSet.Units);
// Find an existing RegUnitSet.
- std::vector<RegUnitSet>::const_iterator SetI =
- findRegUnitSet(RegUnitSets, RUSet);
- if (SetI != std::prev(RegUnitSets.end()))
- RegUnitSets.pop_back();
+ if (findRegUnitSet(RegUnitSets, RUSet) == RegUnitSets.end())
+ RegUnitSets.push_back(std::move(RUSet));
}
if (RegUnitSets.empty())
@@ -2042,11 +2038,9 @@ void CodeGenRegBank::computeRegUnitSets() {
if (Intersection.empty())
continue;
- // Speculatively grow the RegUnitSets to hold the new set.
- RegUnitSet &RUSet = RegUnitSets.emplace_back();
+ RegUnitSet RUSet;
RUSet.Name =
RegUnitSets[Idx].Name + "_with_" + RegUnitSets[SearchIdx].Name;
-
std::set_union(RegUnitSets[Idx].Units.begin(),
RegUnitSets[Idx].Units.end(),
RegUnitSets[SearchIdx].Units.begin(),
@@ -2054,16 +2048,13 @@ void CodeGenRegBank::computeRegUnitSets() {
std::inserter(RUSet.Units, RUSet.Units.begin()));
// Find an existing RegUnitSet, or add the union to the unique sets.
- std::vector<RegUnitSet>::const_iterator SetI =
- findRegUnitSet(RegUnitSets, RUSet);
- if (SetI != std::prev(RegUnitSets.end()))
- RegUnitSets.pop_back();
- else {
- LLVM_DEBUG(dbgs() << "UnitSet " << RegUnitSets.size() - 1 << " "
+ if (findRegUnitSet(RegUnitSets, RUSet) == RegUnitSets.end()) {
+ LLVM_DEBUG(dbgs() << "UnitSet " << RegUnitSets.size() << " "
<< RUSet.Name << ":";
for (auto &U
: RUSet.Units) printRegUnitName(U);
dbgs() << "\n";);
+ RegUnitSets.push_back(std::move(RUSet));
}
}
}