diff options
author | Vedant Kumar <vsk@apple.com> | 2020-03-19 16:21:52 -0700 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2020-03-20 12:18:25 -0700 |
commit | 4716ebb823e4a3953d7ea803db1949ff699b96c8 (patch) | |
tree | e511e49af8528d2fd630f101a85db91da85f67f3 /llvm/lib/CodeGen/LiveDebugValues.cpp | |
parent | 25294708f5ee8c0063c9ff20b862aa71cf0eeaad (diff) | |
download | llvm-4716ebb823e4a3953d7ea803db1949ff699b96c8.zip llvm-4716ebb823e4a3953d7ea803db1949ff699b96c8.tar.gz llvm-4716ebb823e4a3953d7ea803db1949ff699b96c8.tar.bz2 |
[ADT] CoalescingBitVector: Avoid initial heap allocation, NFC
Avoid making a heap allocation when constructing a CoalescingBitVector.
This reduces time spent in LiveDebugValues when compiling sqlite3 by
700ms (0.5% of the total User Time).
rdar://60046261
Differential Revision: https://reviews.llvm.org/D76465
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugValues.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues.cpp b/llvm/lib/CodeGen/LiveDebugValues.cpp index a013c41..89c3bcf 100644 --- a/llvm/lib/CodeGen/LiveDebugValues.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues.cpp @@ -482,7 +482,8 @@ private: } }; - using VarLocInMBB = SmallDenseMap<const MachineBasicBlock *, VarLocSet>; + using VarLocInMBB = + SmallDenseMap<const MachineBasicBlock *, std::unique_ptr<VarLocSet>>; struct TransferDebugPair { MachineInstr *TransferInst; ///< Instruction where this transfer occurs. LocIndex LocationID; ///< Location number for the transfer dest. @@ -573,15 +574,17 @@ private: SmallVectorImpl<uint32_t> &UsedRegs) const; VarLocSet &getVarLocsInMBB(const MachineBasicBlock *MBB, VarLocInMBB &Locs) { - auto Result = Locs.try_emplace(MBB, Alloc); - return Result.first->second; + std::unique_ptr<VarLocSet> &VLS = Locs[MBB]; + if (!VLS) + VLS = std::make_unique<VarLocSet>(Alloc); + return *VLS.get(); } 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.get(); } /// Tests whether this instruction is a spill to a stack location. @@ -1479,10 +1482,11 @@ bool LiveDebugValues::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.get(); if (!NumVisited) - InLocsT = OL->second; + InLocsT = OutLocVLS; else - InLocsT &= OL->second; + InLocsT &= OutLocVLS; LLVM_DEBUG({ if (!InLocsT.empty()) { @@ -1554,7 +1558,7 @@ void LiveDebugValues::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.get(); for (uint64_t ID : Pending) { // The ID location is live-in to MBB -- work out what kind of machine @@ -1703,7 +1707,7 @@ bool LiveDebugValues::ExtendRanges(MachineFunction &MF) { // Initialize per-block structures and scan for fragment overlaps. for (auto &MBB : MF) { - PendingInLocs.try_emplace(&MBB, Alloc); + PendingInLocs[&MBB] = std::make_unique<VarLocSet>(Alloc); for (auto &MI : MBB) { if (MI.isDebugValue()) |