llvm.org GIT mirror llvm / 6c76d11
SelectionDAG: Introduce PersistentID to SDNode for assert builds. This gives us more human readable numbers to identify nodes in debug dumps. Before: 0x7fcbd9700160: ch = EntryToken 0x7fcbd985c7c8: i64 = Register %RAX ... 0x7fcbd9700160: <multiple use> 0x7fcbd985c578: i64,ch = MOV64rm 0x7fcbd985c6a0, 0x7fcbd985cc68, 0x7fcbd985c200, 0x7fcbd985cd90, 0x7fcbd985ceb8, 0x7fcbd9700160<Mem:LD8[@foo]> [ORD=2] 0x7fcbd985c8f0: ch,glue = CopyToReg 0x7fcbd9700160, 0x7fcbd985c7c8, 0x7fcbd985c578 [ORD=3] 0x7fcbd985c7c8: <multiple use> 0x7fcbd985c8f0: <multiple use> 0x7fcbd985c8f0: <multiple use> 0x7fcbd985ca18: ch = RETQ 0x7fcbd985c7c8, 0x7fcbd985c8f0, 0x7fcbd985c8f0:1 [ORD=3] Now: t0: ch = EntryToken t5: i64 = Register %RAX ... t0: <multiple use> t3: i64,ch = MOV64rm t10, t12, t11, t13, t14, t0<Mem:LD8[@foo]> [ORD=2] t6: ch,glue = CopyToReg t0, t5, t3 [ORD=3] t5: <multiple use> t6: <multiple use> t6: <multiple use> t7: ch = RETQ t5, t6, t6:1 [ORD=3] Differential Revision: http://reviews.llvm.org/D12564 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248010 91177308-0d34-0410-b5e6-96231b3b80d8 Matthias Braun 5 years ago
7 changed file(s) with 46 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
213213
214214 /// Tracks dbg_value information through SDISel.
215215 SDDbgInfo *DbgInfo;
216
217 #ifndef NDEBUG
218 uint16_t NextPersistentId;
219 #endif
216220
217221 public:
218222 /// Clients of various APIs that cause global effects on
430430 friend struct ilist_traits;
431431
432432 public:
433 #ifndef NDEBUG
434 /// Unique and persistent id per SDNode in the DAG.
435 /// Used for debug printing.
436 uint16_t PersistentId;
437 #endif
438
433439 //===--------------------------------------------------------------------===//
434440 // Accessors
435441 //
762762 void SelectionDAG::InsertNode(SDNode *N) {
763763 AllNodes.push_back(N);
764764 #ifndef NDEBUG
765 N->PersistentId = NextPersistentId++;
765766 VerifySDNode(N);
766767 #endif
767768 }
947948 AllNodes.remove(AllNodes.begin());
948949 while (!AllNodes.empty())
949950 DeallocateNode(AllNodes.begin());
951 #ifndef NDEBUG
952 NextPersistentId = 0;
953 #endif
950954 }
951955
952956 BinarySDNode *SelectionDAG::GetBinarySDNode(unsigned Opcode, SDLoc DL,
360360 }
361361 }
362362
363 namespace {
364 class PrintNodeId {
365 const SDNode &Node;
366 public:
367 explicit PrintNodeId(const SDNode &Node)
368 : Node(Node) {}
369 void print(raw_ostream &OS) const {
370 #ifndef NDEBUG
371 OS << 't' << Node.PersistentId;
372 #else
373 OS << (const void*)&Node;
374 #endif
375 }
376 };
377
378 static inline raw_ostream &operator<<(raw_ostream &OS, const PrintNodeId &P) {
379 P.print(OS);
380 return OS;
381 }
382 }
383
363384 void SDNode::dump() const { dump(nullptr); }
364385 void SDNode::dump(const SelectionDAG *G) const {
365386 print(dbgs(), G);
367388 }
368389
369390 void SDNode::print_types(raw_ostream &OS, const SelectionDAG *G) const {
370 OS << (const void*)this << ": ";
391 OS << PrintNodeId(*this) << ": ";
371392
372393 for (unsigned i = 0, e = getNumValues(); i != e; ++i) {
373394 if (i) OS << ",";
559580 DumpNodes(Op.getNode(), indent+2, G);
560581 else
561582 dbgs() << "\n" << std::string(indent+2, ' ')
562 << (void*)Op.getNode() << ": ";
583 << PrintNodeId(*Op.getNode()) << ": ";
563584
564585 dbgs() << '\n';
565586 dbgs().indent(indent);
675696 print_types(OS, G);
676697 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
677698 if (i) OS << ", "; else OS << " ";
678 OS << (void*)getOperand(i).getNode();
679 if (unsigned RN = getOperand(i).getResNo())
699 const SDValue Operand = getOperand(i);
700 OS << PrintNodeId(*Operand.getNode());
701 if (unsigned RN = Operand.getResNo())
680702 OS << ":" << RN;
681703 }
682704 print_details(OS, G);
99 ret void
1010
1111 ; FIXME: Crashing is not really the correct behavior here, we really should just emit nothing
12 ; CHECK: Cannot select: 0x{{[0-9,a-f]+}}: ch = Prefetch
13 ; CHECK: 0x{{[0-9,a-f]+}}: i32 = Constant<0>
14 ; CHECK-NEXT: 0x{{[0-9,a-f]+}}: i32 = Constant<3>
15 ; CHECK-NEXT: 0x{{[0-9,a-f]+}}: i32 = Constant<0>
12 ; CHECK: Cannot select: {{0x[0-9,a-f]+|t[0-9]+}}: ch = Prefetch
13 ; CHECK: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = Constant<0>
14 ; CHECK-NEXT: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = Constant<3>
15 ; CHECK-NEXT: {{0x[0-9,a-f]+|t[0-9]+}}: i32 = Constant<0>
1616
1717 }
1818
0 ; RUN: llc -debug < %s 2>&1 | FileCheck %s
11 ; REQUIRES: asserts
22
3 ; CHECK: 0x{{[0-9,a-f]+}}: i32 = Constant<-1>test.c:4:5
3 ; CHECK: t{{[0-9]+}}: i32 = Constant<-1>test.c:4:5
44
55 define i32 @main() {
66 entry:
0 ; RUN: llc -debug < %s 2>&1 | FileCheck %s
11 ; REQUIRES: asserts
22
3 ; CHECK: 0x{{[0-9,a-f]+}}: f64 = ConstantFP<1.500000e+00>test.c:3:5
3 ; CHECK: t{{[0-9]+}}: f64 = ConstantFP<1.500000e+00>test.c:3:5
44
55 define double @f() {
66 entry: