diff options
author | Bjorn Pettersson <bjorn.a.pettersson@ericsson.com> | 2018-03-21 09:44:34 +0000 |
---|---|---|
committer | Bjorn Pettersson <bjorn.a.pettersson@ericsson.com> | 2018-03-21 09:44:34 +0000 |
commit | 5c25f8853682fca39f08b24be846bfbf18006cee (patch) | |
tree | 8b95edb99ca9f8d9cd88fdf16cdc9e1d73d2941a /llvm/lib | |
parent | 95f7572c6f57facd227e882a9d775c348d8e03ee (diff) | |
download | bcm5719-llvm-5c25f8853682fca39f08b24be846bfbf18006cee.tar.gz bcm5719-llvm-5c25f8853682fca39f08b24be846bfbf18006cee.zip |
[SelectionDAG] Support multiple dangling debug info for one value
Summary:
When building the selection DAG we sometimes need to postpone
the handling of a dbg.value until the value it should refer to
is created. This is done by using the DanglingDebugInfoMap.
In the past this map has been limited to hold one dangling
dbg.value per value. This patch removes that restriction.
Reviewers: aprantl, rnk, probinson, vsk
Reviewed By: aprantl
Subscribers: Ka-Ka, llvm-commits, JDevlieghere
Tags: #debug-info
Differential Revision: https://reviews.llvm.org/D44610
llvm-svn: 328084
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 95 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h | 5 |
2 files changed, 50 insertions, 50 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 5de9566785b..2a6f958c3bc 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1080,62 +1080,59 @@ void SelectionDAGBuilder::visit(unsigned Opcode, const User &I) { void SelectionDAGBuilder::dropDanglingDebugInfo(const DILocalVariable *Variable, const DIExpression *Expr) { - SmallVector<const Value *, 4> ToRemove; - for (auto &DMI : DanglingDebugInfoMap) { - DanglingDebugInfo &DDI = DMI.second; - if (DDI.getDI()) { - const DbgValueInst *DI = DDI.getDI(); - DIVariable *DanglingVariable = DI->getVariable(); - DIExpression *DanglingExpr = DI->getExpression(); - if (DanglingVariable == Variable && - Expr->fragmentsOverlap(DanglingExpr)) { - DEBUG(dbgs() << "Dropping dangling debug info for " << *DI << "\n"); - ToRemove.push_back(DMI.first); + 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)) { + DEBUG(dbgs() << "Dropping dangling debug info for " << *DI << "\n"); + DDI = DanglingDebugInfo(); + } } - } - } - - for (auto V : ToRemove) - DanglingDebugInfoMap[V] = DanglingDebugInfo(); } // 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) { - DanglingDebugInfo &DDI = DanglingDebugInfoMap[V]; - if (!DDI.getDI()) - return; - const DbgValueInst *DI = DDI.getDI(); - DebugLoc dl = DDI.getdl(); - unsigned ValSDNodeOrder = Val.getNode()->getIROrder(); - unsigned DbgSDNodeOrder = DDI.getSDNodeOrder(); - DILocalVariable *Variable = DI->getVariable(); - DIExpression *Expr = DI->getExpression(); - assert(Variable->isValidLocationForIntrinsic(dl) && - "Expected inlined-at fields to agree"); - SDDbgValue *SDV; - if (Val.getNode()) { - if (!EmitFuncArgumentDbgValue(V, Variable, Expr, dl, false, Val)) { - DEBUG(dbgs() << "Resolve dangling debug info [order=" << DbgSDNodeOrder - << "] for:\n " << *DI << "\n"); - DEBUG(dbgs() << " By mapping to:\n "; Val.dump()); - // Increase the SDNodeOrder for the DbgValue here to make sure it is - // inserted after the definition of Val when emitting the instructions - // after ISel. An alternative could be to teach - // ScheduleDAGSDNodes::EmitSchedule to delay the insertion properly. - DEBUG(if (ValSDNodeOrder > DbgSDNodeOrder) - dbgs() << "changing SDNodeOrder from " << DbgSDNodeOrder - << " to " << ValSDNodeOrder << "\n"); - SDV = getDbgValue(Val, Variable, Expr, dl, - std::max(DbgSDNodeOrder, ValSDNodeOrder)); - DAG.AddDbgValue(SDV, Val.getNode(), false); + DanglingDebugInfoVector &DDIV = DanglingDebugInfoMap[V]; + for (auto &DDI : DDIV) { + if (!DDI.getDI()) + continue; + const DbgValueInst *DI = DDI.getDI(); + DebugLoc dl = DDI.getdl(); + unsigned ValSDNodeOrder = Val.getNode()->getIROrder(); + unsigned DbgSDNodeOrder = DDI.getSDNodeOrder(); + DILocalVariable *Variable = DI->getVariable(); + DIExpression *Expr = DI->getExpression(); + assert(Variable->isValidLocationForIntrinsic(dl) && + "Expected inlined-at fields to agree"); + SDDbgValue *SDV; + if (Val.getNode()) { + if (!EmitFuncArgumentDbgValue(V, Variable, Expr, dl, false, Val)) { + DEBUG(dbgs() << "Resolve dangling debug info [order=" << DbgSDNodeOrder + << "] for:\n " << *DI << "\n"); + DEBUG(dbgs() << " By mapping to:\n "; Val.dump()); + // Increase the SDNodeOrder for the DbgValue here to make sure it is + // inserted after the definition of Val when emitting the instructions + // after ISel. An alternative could be to teach + // ScheduleDAGSDNodes::EmitSchedule to delay the insertion properly. + DEBUG(if (ValSDNodeOrder > DbgSDNodeOrder) + dbgs() << "changing SDNodeOrder from " << DbgSDNodeOrder + << " to " << ValSDNodeOrder << "\n"); + SDV = getDbgValue(Val, Variable, Expr, dl, + std::max(DbgSDNodeOrder, ValSDNodeOrder)); + DAG.AddDbgValue(SDV, Val.getNode(), false); + } else + DEBUG(dbgs() << "Resolved dangling debug info for " << *DI + << "in EmitFuncArgumentDbgValue\n"); } else - DEBUG(dbgs() << "Resolved dangling debug info for " << *DI - << "in EmitFuncArgumentDbgValue\n"); - } else - DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); - DanglingDebugInfoMap[V] = DanglingDebugInfo(); + DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n"); + } + DanglingDebugInfoMap[V].clear(); } /// getCopyFromRegs - If there was virtual register allocated for the value V @@ -5330,7 +5327,7 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) { // 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] = DDI; + DanglingDebugInfoMap[V].push_back(DDI); return nullptr; } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h index 3d58a040e2a..94f7d5821ad 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -116,9 +116,12 @@ class SelectionDAGBuilder { unsigned getSDNodeOrder() { return SDNodeOrder; } }; + /// DanglingDebugInfoVector - Helper type for DanglingDebugInfoMap. + typedef std::vector<DanglingDebugInfo> DanglingDebugInfoVector; + /// DanglingDebugInfoMap - Keeps track of dbg_values for which we have not /// yet seen the referent. We defer handling these until we do see it. - DenseMap<const Value*, DanglingDebugInfo> DanglingDebugInfoMap; + DenseMap<const Value*, DanglingDebugInfoVector> DanglingDebugInfoMap; public: /// PendingLoads - Loads are not emitted to the program immediately. We bunch |