[llvm] r337751 - [SelectionDAG] Reduce DanglingDebugInfo memory traffic, NFC
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 23 14:59:04 PDT 2018
Author: vedantk
Date: Mon Jul 23 14:59:04 2018
New Revision: 337751
URL: http://llvm.org/viewvc/llvm-project?rev=337751&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=337751&r1=337750&r2=337751&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Mon Jul 23 14:59:04 2018
@@ -1093,30 +1093,35 @@ void SelectionDAGBuilder::visit(unsigned
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::resolveDanglin
} 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(
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;
}
More information about the llvm-commits
mailing list