Index: include/llvm/CodeGen/SelectionDAG.h =================================================================== --- include/llvm/CodeGen/SelectionDAG.h +++ include/llvm/CodeGen/SelectionDAG.h @@ -1358,21 +1358,20 @@ /// with this SelectionDAG. bool hasDebugValues() const { return !DbgInfo->empty(); } - SDDbgInfo::DbgIterator DbgBegin() { return DbgInfo->DbgBegin(); } - SDDbgInfo::DbgIterator DbgEnd() { return DbgInfo->DbgEnd(); } + SDDbgInfo::DbgIterator DbgBegin() const { return DbgInfo->DbgBegin(); } + SDDbgInfo::DbgIterator DbgEnd() const { return DbgInfo->DbgEnd(); } - SDDbgInfo::DbgIterator ByvalParmDbgBegin() { + SDDbgInfo::DbgIterator ByvalParmDbgBegin() const { return DbgInfo->ByvalParmDbgBegin(); } - - SDDbgInfo::DbgIterator ByvalParmDbgEnd() { + SDDbgInfo::DbgIterator ByvalParmDbgEnd() const { return DbgInfo->ByvalParmDbgEnd(); } - SDDbgInfo::DbgLabelIterator DbgLabelBegin() { + SDDbgInfo::DbgLabelIterator DbgLabelBegin() const { return DbgInfo->DbgLabelBegin(); } - SDDbgInfo::DbgLabelIterator DbgLabelEnd() { + SDDbgInfo::DbgLabelIterator DbgLabelEnd() const { return DbgInfo->DbgLabelEnd(); } Index: lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp @@ -145,6 +145,8 @@ unsigned IID = cast(getOperand(OpNo))->getZExtValue(); if (IID < Intrinsic::num_intrinsics) return Intrinsic::getName((Intrinsic::ID)IID, None); + else if (!G) + return "Unknown intrinsic"; else if (const TargetIntrinsicInfo *TII = G->getTarget().getIntrinsicInfo()) return TII->getName(IID); llvm_unreachable("Invalid intrinsic ID"); @@ -684,39 +686,43 @@ if (getNodeId() != -1) OS << " [ID=" << getNodeId() << ']'; if (!(isa(this) || (isa(this)))) - OS << "# D:" << isDivergent(); - - if (!G) - return; - - DILocation *L = getDebugLoc(); - if (!L) - return; - - if (auto *Scope = L->getScope()) - OS << Scope->getFilename(); - else - OS << ""; - OS << ':' << L->getLine(); - if (unsigned C = L->getColumn()) - OS << ':' << C; - - for (SDDbgValue *Dbg : G->GetDbgValues(this)) { - if (Dbg->getKind() != SDDbgValue::SDNODE || Dbg->isInvalidated()) - continue; - Dbg->dump(OS); - } + OS << " # D:" << isDivergent(); + + if (G && !G->GetDbgValues(this).empty()) { + OS << " [NoOfDbgValues=" << G->GetDbgValues(this).size() << ']'; + for (SDDbgValue *Dbg : G->GetDbgValues(this)) { + if (Dbg->getKind() != SDDbgValue::SDNODE || Dbg->isInvalidated()) + continue; + Dbg->dump(OS); + } + } else if (getHasDebugValue()) + OS << " [NoOfDbgValues>0]"; } } LLVM_DUMP_METHOD void SDDbgValue::dump(raw_ostream &OS) const { - OS << " DbgVal"; - if (kind==SDNODE) - OS << '(' << u.s.ResNo << ')'; - OS << ":\"" << Var->getName() << '"'; + OS << " DbgVal(Order=" << getOrder() << ')'; + switch (getKind()) { + case SDNODE: + if (getSDNode()) + OS << "(SDNODE=" << PrintNodeId(*getSDNode()) << ':' << getResNo() << ')'; + else + OS << "(SDNODE)"; + break; + case CONST: + OS << "(CONST)"; + break; + case FRAMEIX: + OS << "(FRAMEIX=" << getFrameIx() << ')'; + break; + case VREG: + OS << "(VREG=" << getVReg() << ')'; + break; + } + OS << ":\"" << Var->getName() << '"'; #ifndef NDEBUG - if (Expr->getNumElements()) - Expr->dump(); + if (Expr->getNumElements()) + Expr->dump(); #endif } @@ -753,7 +759,22 @@ } if (getRoot().getNode()) DumpNodes(getRoot().getNode(), 2, this); - dbgs() << "\n\n"; + dbgs() << "\n"; + + if (VerboseDAGDumping) { + for (const SDDbgValue *Dbg : make_range(DbgBegin(), + DbgEnd())) { + Dbg->dump(dbgs()); + dbgs() << "\n"; + } + for (const SDDbgValue *Dbg : make_range(ByvalParmDbgBegin(), + ByvalParmDbgEnd())) { + dbgs() << "Byval "; + Dbg->dump(dbgs()); + dbgs() << "\n"; + } + } + dbgs() << "\n"; } #endif