diff options
author | Vedant Kumar <vsk@apple.com> | 2018-07-23 21:59:04 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2018-07-23 21:59:04 +0000 |
commit | 22bd6f99fabe16a214268ca3f4ba0fffaddbab39 (patch) | |
tree | 69ac967c7a237124ed2cdd05cabada5986dd2ed4 | |
parent | e214fdeb69244a3e0c77343d791e761694f2c3b0 (diff) | |
download | bcm5719-llvm-22bd6f99fabe16a214268ca3f4ba0fffaddbab39.tar.gz bcm5719-llvm-22bd6f99fabe16a214268ca3f4ba0fffaddbab39.zip |
[SelectionDAG] Reduce DanglingDebugInfo memory traffic, NFC
This avoids approx. 2 x 10^5 DenseMap insertions in both non-debug and
debug -O2 builds of the sqlite3 amalgamation.
llvm-svn: 337751
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index f91cf709df5..1e36ea049b1 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1093,30 +1093,35 @@ void SelectionDAGBuilder::visit(unsigned Opcode, const User &I) { void SelectionDAGBuilder::dropDanglingDebugInfo(const DILocalVariable *Variable, const DIExpression *Expr) { - for (auto &DDIMI : DanglingDebugInfoMap) - for (auto &DDI : DDIMI.second) - if (DDI.getDI()) { - const DbgValueInst *DI = DDI.getDI(); - DIVariable *DanglingVariable = DI->getVariable(); - DIExpression *DanglingExpr = DI->getExpression(); - if (DanglingVariable == Variable && - Expr->fragmentsOverlap(DanglingExpr)) { - LLVM_DEBUG(dbgs() - << "Dropping dangling debug info for " << *DI << "\n"); - DDI = DanglingDebugInfo(); - } - } + auto isMatchingDbgValue = [&](DanglingDebugInfo &DDI) { + const DbgValueInst *DI = DDI.getDI(); + DIVariable *DanglingVariable = DI->getVariable(); + DIExpression *DanglingExpr = DI->getExpression(); + if (DanglingVariable == Variable && Expr->fragmentsOverlap(DanglingExpr)) { + LLVM_DEBUG(dbgs() << "Dropping dangling debug info for " << *DI << "\n"); + return true; + } + return false; + }; + + for (auto &DDIMI : DanglingDebugInfoMap) { + DanglingDebugInfoVector &DDIV = DDIMI.second; + DDIV.erase(remove_if(DDIV, isMatchingDbgValue), DDIV.end()); + } } // resolveDanglingDebugInfo - if we saw an earlier dbg_value referring to V, // generate the debug data structures now that we've seen its definition. void SelectionDAGBuilder::resolveDanglingDebugInfo(const Value *V, SDValue Val) { - DanglingDebugInfoVector &DDIV = DanglingDebugInfoMap[V]; + auto DanglingDbgInfoIt = DanglingDebugInfoMap.find(V); + if (DanglingDbgInfoIt == DanglingDebugInfoMap.end()) + return; + + DanglingDebugInfoVector &DDIV = DanglingDbgInfoIt->second; for (auto &DDI : DDIV) { - if (!DDI.getDI()) - continue; const DbgValueInst *DI = DDI.getDI(); + assert(DI && "Ill-formed DanglingDebugInfo"); DebugLoc dl = DDI.getdl(); unsigned ValSDNodeOrder = Val.getNode()->getIROrder(); unsigned DbgSDNodeOrder = DDI.getSDNodeOrder(); @@ -1146,7 +1151,7 @@ void SelectionDAGBuilder::resolveDanglingDebugInfo(const Value *V, } else LLVM_DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); } - DanglingDebugInfoMap[V].clear(); + DDIV.clear(); } /// getCopyFromRegs - If there was virtual register allocated for the value V @@ -5320,8 +5325,7 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) { if (!V->use_empty() ) { // Do not call getValue(V) yet, as we don't want to generate code. // Remember it for later. - DanglingDebugInfo DDI(&DI, dl, SDNodeOrder); - DanglingDebugInfoMap[V].push_back(DDI); + DanglingDebugInfoMap[V].emplace_back(&DI, dl, SDNodeOrder); return nullptr; } |