Skip to content

Commit

Permalink
Allow CoalescingBitVector to be movable
Browse files Browse the repository at this point in the history
  • Loading branch information
dc03 committed Jun 22, 2023
1 parent 44e63ff commit 9a1d7a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
10 changes: 8 additions & 2 deletions llvm/include/llvm/ADT/CoalescingBitVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ template <typename IndexT> class CoalescingBitVector {
return *this;
}

CoalescingBitVector(ThisT &&Other) = delete;
ThisT &operator=(ThisT &&Other) = delete;
CoalescingBitVector(ThisT &&Other) noexcept
: Alloc(Other.Alloc), Intervals(std::move_if_noexcept(Other.Intervals)) {}

ThisT &operator=(ThisT &&Other) noexcept {
Alloc = Other.Alloc;
Intervals = std::move_if_noexcept(Other.Intervals);
return *this;
}

/// @}

Expand Down
13 changes: 5 additions & 8 deletions llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ class VarLocBasedLDV : public LDVImpl {
};

using VarLocInMBB =
SmallDenseMap<const MachineBasicBlock *, std::unique_ptr<VarLocSet>>;
SmallDenseMap<const MachineBasicBlock *, VarLocSet>;
struct TransferDebugPair {
MachineInstr *TransferInst; ///< Instruction where this transfer occurs.
LocIndex LocationID; ///< Location number for the transfer dest.
Expand Down Expand Up @@ -987,17 +987,14 @@ class VarLocBasedLDV : public LDVImpl {
const VarLocMap &VarLocIDs);

VarLocSet &getVarLocsInMBB(const MachineBasicBlock *MBB, VarLocInMBB &Locs) {
std::unique_ptr<VarLocSet> &VLS = Locs[MBB];
if (!VLS)
VLS = std::make_unique<VarLocSet>(Alloc);
return *VLS;
return Locs.try_emplace(MBB, Alloc).first->second;
}

const VarLocSet &getVarLocsInMBB(const MachineBasicBlock *MBB,
const VarLocInMBB &Locs) const {
auto It = Locs.find(MBB);
assert(It != Locs.end() && "MBB not in map");
return *It->second;
return It->second;
}

/// Tests whether this instruction is a spill to a stack location.
Expand Down Expand Up @@ -2042,7 +2039,7 @@ bool VarLocBasedLDV::join(

// Just copy over the Out locs to incoming locs for the first visited
// predecessor, and for all other predecessors join the Out locs.
VarLocSet &OutLocVLS = *OL->second;
VarLocSet &OutLocVLS = OL->second;
if (!NumVisited)
InLocsT = OutLocVLS;
else
Expand Down Expand Up @@ -2101,7 +2098,7 @@ void VarLocBasedLDV::flushPendingLocs(VarLocInMBB &PendingInLocs,
for (auto &Iter : PendingInLocs) {
// Map is keyed on a constant pointer, unwrap it so we can insert insts.
auto &MBB = const_cast<MachineBasicBlock &>(*Iter.first);
VarLocSet &Pending = *Iter.second;
VarLocSet &Pending = Iter.second;

SmallVector<VarLoc, 32> VarLocs;
collectAllVarLocs(VarLocs, Pending, VarLocIDs);
Expand Down

0 comments on commit 9a1d7a2

Please sign in to comment.