diff options
author | Vedant Kumar <vsk@apple.com> | 2020-05-28 15:57:11 -0700 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2020-06-04 16:58:45 -0700 |
commit | 198762680e1e66518ee531c9cce5bf1933accea3 (patch) | |
tree | 0f56aa0a506eb5021ed8c577cacc63b1415b4b18 /llvm/lib/CodeGen/LiveDebugValues.cpp | |
parent | c0cd1f1c5cc97e0c90727b3e4d5f52dd6a7aae55 (diff) | |
download | llvm-198762680e1e66518ee531c9cce5bf1933accea3.zip llvm-198762680e1e66518ee531c9cce5bf1933accea3.tar.gz llvm-198762680e1e66518ee531c9cce5bf1933accea3.tar.bz2 |
[LiveDebugValues] Cache LexicalScopes::getMachineBasicBlocks, NFCI
Summary:
Cache the results from getMachineBasicBlocks in LexicalScopes to speed
up UserValueScopes::dominates queries. This replaces the caching done
in UserValueScopes. Compared to the old caching method, this reduces
memory traffic when a VarLoc is copied (e.g. when a VarLocMap grows),
and enables caching across basic blocks.
When compiling sqlite 3.5.7 (CTMark version), this patch reduces the
number of calls to getMachineBasicBlocks from 10,207 to 1,093. I also
measured a small compile-time reduction (~ 0.1% of total wall time, on
average, on my machine).
As a drive-by, I made the DebugLoc in UserValueScopes a const reference
to cut down on MetadataTracking traffic.
Reviewers: jmorse, Orlando, aprantl, nikic
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D80957
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugValues.cpp')
-rw-r--r-- | llvm/lib/CodeGen/LiveDebugValues.cpp | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/llvm/lib/CodeGen/LiveDebugValues.cpp b/llvm/lib/CodeGen/LiveDebugValues.cpp index 85fb83d..03be54a 100644 --- a/llvm/lib/CodeGen/LiveDebugValues.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues.cpp @@ -200,25 +200,6 @@ private: enum struct TransferKind { TransferCopy, TransferSpill, TransferRestore }; - /// Keeps track of lexical scopes associated with a user value's source - /// location. - class UserValueScopes { - DebugLoc DL; - LexicalScopes &LS; - SmallPtrSet<const MachineBasicBlock *, 4> LBlocks; - - public: - UserValueScopes(DebugLoc D, LexicalScopes &L) : DL(std::move(D)), LS(L) {} - - /// Return true if current scope dominates at least one machine - /// instruction in a given machine basic block. - bool dominates(MachineBasicBlock *MBB) { - if (LBlocks.empty()) - LS.getMachineBasicBlocks(DL, LBlocks); - return LBlocks.count(MBB) != 0 || LS.dominates(DL, MBB); - } - }; - using FragmentInfo = DIExpression::FragmentInfo; using OptFragmentInfo = Optional<DIExpression::FragmentInfo>; @@ -247,7 +228,6 @@ private: /// is moved. const MachineInstr &MI; - mutable UserValueScopes UVS; enum VarLocKind { InvalidKind = 0, RegisterKind, @@ -272,7 +252,7 @@ private: VarLoc(const MachineInstr &MI, LexicalScopes &LS) : Var(MI.getDebugVariable(), MI.getDebugExpression(), MI.getDebugLoc()->getInlinedAt()), - Expr(MI.getDebugExpression()), MI(MI), UVS(MI.getDebugLoc(), LS) { + Expr(MI.getDebugExpression()), MI(MI) { static_assert((sizeof(Loc) == sizeof(uint64_t)), "hash does not cover all members of Loc"); assert(MI.isDebugValue() && "not a DBG_VALUE"); @@ -438,7 +418,9 @@ private: /// Determine whether the lexical scope of this value's debug location /// dominates MBB. - bool dominates(MachineBasicBlock &MBB) const { return UVS.dominates(&MBB); } + bool dominates(LexicalScopes &LS, MachineBasicBlock &MBB) const { + return LS.dominates(MI.getDebugLoc().get(), &MBB); + } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) // TRI can be null. @@ -1615,7 +1597,7 @@ bool LiveDebugValues::join( if (!IsArtificial) { for (uint64_t ID : InLocsT) { LocIndex Idx = LocIndex::fromRawInteger(ID); - if (!VarLocIDs[Idx].dominates(MBB)) { + if (!VarLocIDs[Idx].dominates(LS, MBB)) { KillSet.set(ID); LLVM_DEBUG({ auto Name = VarLocIDs[Idx].Var.getVariable()->getName(); |