summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-09-18 17:41:00 +0000
committerMatthias Braun <matze@braunis.de>2015-09-18 17:41:00 +0000
commit0b7d6c14c9ef2c6ff3b27486e8ad28faf28ae5e0 (patch)
tree5712e4e89d6f854eda230a6ae4bd2b50c751b368 /llvm/lib/CodeGen/SelectionDAG
parent08249706cd640738af7e294816c3c52cc998ce04 (diff)
downloadbcm5719-llvm-0b7d6c14c9ef2c6ff3b27486e8ad28faf28ae5e0.tar.gz
bcm5719-llvm-0b7d6c14c9ef2c6ff3b27486e8ad28faf28ae5e0.zip
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 llvm-svn: 248010
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp4
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp30
2 files changed, 30 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 455fc90bce9..e2e34dbf07a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -763,6 +763,7 @@ static void VerifySDNode(SDNode *N) {
void SelectionDAG::InsertNode(SDNode *N) {
AllNodes.push_back(N);
#ifndef NDEBUG
+ N->PersistentId = NextPersistentId++;
VerifySDNode(N);
#endif
}
@@ -948,6 +949,9 @@ void SelectionDAG::allnodes_clear() {
AllNodes.remove(AllNodes.begin());
while (!AllNodes.empty())
DeallocateNode(AllNodes.begin());
+#ifndef NDEBUG
+ NextPersistentId = 0;
+#endif
}
BinarySDNode *SelectionDAG::GetBinarySDNode(unsigned Opcode, SDLoc DL,
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
index a625e4973fd..707cfad3ded 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
@@ -361,6 +361,27 @@ const char *SDNode::getIndexedModeName(ISD::MemIndexedMode AM) {
}
}
+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::dump(const SelectionDAG *G) const {
}
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 @@ static void DumpNodes(const SDNode *N, unsigned indent, const SelectionDAG *G) {
DumpNodes(Op.getNode(), indent+2, G);
else
dbgs() << "\n" << std::string(indent+2, ' ')
- << (void*)Op.getNode() << ": <multiple use>";
+ << PrintNodeId(*Op.getNode()) << ": <multiple use>";
dbgs() << '\n';
dbgs().indent(indent);
@@ -676,8 +697,9 @@ void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const {
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);
OpenPOWER on IntegriCloud