Index: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h @@ -215,6 +215,10 @@ /// Tracks dbg_value information through SDISel. SDDbgInfo *DbgInfo; +#ifndef NDEBUG + uint16_t NextPersistentId; +#endif + public: /// Clients of various APIs that cause global effects on /// the DAG can optionally implement this interface. This allows the clients Index: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h @@ -431,6 +431,12 @@ friend struct ilist_traits; public: +#ifndef NDEBUG + /// Unique and persistent id per SDNode in the DAG. + /// Used for debug printing. + uint16_t PersistentId; +#endif + //===--------------------------------------------------------------------===// // Accessors // Index: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp =================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -763,6 +763,7 @@ void SelectionDAG::InsertNode(SDNode *N) { AllNodes.push_back(N); #ifndef NDEBUG + N->PersistentId = NextPersistentId++; VerifySDNode(N); #endif } @@ -948,6 +949,9 @@ AllNodes.remove(AllNodes.begin()); while (!AllNodes.empty()) DeallocateNode(AllNodes.begin()); +#ifndef NDEBUG + NextPersistentId = 0; +#endif } BinarySDNode *SelectionDAG::GetBinarySDNode(unsigned Opcode, SDLoc DL, Index: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp =================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp @@ -361,6 +361,27 @@ } } +namespace { +class PrintNodeId { + const SDNode &Node; +public: + explicit PrintNodeId(const SDNode &Node) + : Node(Node) {} + void print(raw_ostream &OS) const { +#ifndef NDEBUG + OS << 't' << Node.PersistentId; +#else + OS << (const void*)&Node; +#endif + } +}; + +static inline raw_ostream &operator<<(raw_ostream &OS, const PrintNodeId &P) { + P.print(OS); + return OS; +} +} + void SDNode::dump() const { dump(nullptr); } void SDNode::dump(const SelectionDAG *G) const { print(dbgs(), G); @@ -368,7 +389,7 @@ } void SDNode::print_types(raw_ostream &OS, const SelectionDAG *G) const { - OS << (const void*)this << ": "; + OS << PrintNodeId(*this) << ": "; for (unsigned i = 0, e = getNumValues(); i != e; ++i) { if (i) OS << ","; @@ -560,7 +581,7 @@ DumpNodes(Op.getNode(), indent+2, G); else dbgs() << "\n" << std::string(indent+2, ' ') - << (void*)Op.getNode() << ": "; + << PrintNodeId(*Op.getNode()) << ": "; dbgs() << '\n'; dbgs().indent(indent); @@ -676,8 +697,9 @@ print_types(OS, G); for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { if (i) OS << ", "; else OS << " "; - OS << (void*)getOperand(i).getNode(); - if (unsigned RN = getOperand(i).getResNo()) + const SDValue Operand = getOperand(i); + OS << PrintNodeId(*Operand.getNode()); + if (unsigned RN = Operand.getResNo()) OS << ":" << RN; } print_details(OS, G); Index: llvm/trunk/test/CodeGen/PowerPC/ppc64-icbt-pwr7.ll =================================================================== --- llvm/trunk/test/CodeGen/PowerPC/ppc64-icbt-pwr7.ll +++ llvm/trunk/test/CodeGen/PowerPC/ppc64-icbt-pwr7.ll @@ -10,10 +10,10 @@ ret void ; FIXME: Crashing is not really the correct behavior here, we really should just emit nothing -; CHECK: Cannot select: 0x{{[0-9,a-f]+}}: ch = Prefetch -; CHECK: 0x{{[0-9,a-f]+}}: i32 = Constant<0> -; CHECK-NEXT: 0x{{[0-9,a-f]+}}: i32 = Constant<3> -; CHECK-NEXT: 0x{{[0-9,a-f]+}}: i32 = Constant<0> +; CHECK: Cannot select: {{0x[0-9,a-f]+|t[0-9]+}}: ch = Prefetch +; CHECK: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = Constant<0> +; CHECK-NEXT: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = Constant<3> +; CHECK-NEXT: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = Constant<0> } Index: llvm/trunk/test/DebugInfo/Generic/constant-sdnodes-have-dbg-location.ll =================================================================== --- llvm/trunk/test/DebugInfo/Generic/constant-sdnodes-have-dbg-location.ll +++ llvm/trunk/test/DebugInfo/Generic/constant-sdnodes-have-dbg-location.ll @@ -1,7 +1,7 @@ ; RUN: llc -debug < %s 2>&1 | FileCheck %s ; REQUIRES: asserts -; CHECK: 0x{{[0-9,a-f]+}}: i32 = Constant<-1>test.c:4:5 +; CHECK: t{{[0-9]+}}: i32 = Constant<-1>test.c:4:5 define i32 @main() { entry: Index: llvm/trunk/test/DebugInfo/Generic/constantfp-sdnodes-have-dbg-location.ll =================================================================== --- llvm/trunk/test/DebugInfo/Generic/constantfp-sdnodes-have-dbg-location.ll +++ llvm/trunk/test/DebugInfo/Generic/constantfp-sdnodes-have-dbg-location.ll @@ -1,7 +1,7 @@ ; RUN: llc -debug < %s 2>&1 | FileCheck %s ; REQUIRES: asserts -; CHECK: 0x{{[0-9,a-f]+}}: f64 = ConstantFP<1.500000e+00>test.c:3:5 +; CHECK: t{{[0-9]+}}: f64 = ConstantFP<1.500000e+00>test.c:3:5 define double @f() { entry: