Index: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h +++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h @@ -680,6 +680,7 @@ template <> struct GraphTraits { typedef SUnit NodeType; + typedef SUnit *NodeRef; typedef SUnitIterator ChildIteratorType; static inline NodeType *getEntryNode(SUnit *N) { return N; } static inline ChildIteratorType child_begin(NodeType *N) { Index: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h @@ -2056,6 +2056,7 @@ template <> struct GraphTraits { typedef SDNode NodeType; + typedef SDNode *NodeRef; typedef SDNodeIterator ChildIteratorType; static inline NodeType *getEntryNode(SDNode *N) { return N; } static inline ChildIteratorType child_begin(NodeType *N) { Index: llvm/trunk/include/llvm/Support/GraphWriter.h =================================================================== --- llvm/trunk/include/llvm/Support/GraphWriter.h +++ llvm/trunk/include/llvm/Support/GraphWriter.h @@ -59,14 +59,19 @@ typedef DOTGraphTraits DOTTraits; typedef GraphTraits GTraits; - typedef typename GTraits::NodeType NodeType; + typedef typename GTraits::NodeRef NodeRef; typedef typename GTraits::nodes_iterator node_iterator; typedef typename GTraits::ChildIteratorType child_iterator; DOTTraits DTraits; + static_assert(std::is_pointer::value, + "FIXME: Currently GraphWriter requires the NodeRef type to be " + "a pointer.\nThe pointer usage should be moved to " + "DOTGraphTraits, and removed from GraphWriter itself."); + // Writes the edge labels of the node to O and returns true if there are any // edge labels not equal to the empty string "". - bool getEdgeSourceLabels(raw_ostream &O, NodeType *Node) { + bool getEdgeSourceLabels(raw_ostream &O, NodeRef Node) { child_iterator EI = GTraits::child_begin(Node); child_iterator EE = GTraits::child_end(Node); bool hasEdgeSourceLabels = false; @@ -140,31 +145,23 @@ // Loop over the graph, printing it out... for (node_iterator I = GTraits::nodes_begin(G), E = GTraits::nodes_end(G); I != E; ++I) - if (!isNodeHidden(*I)) - writeNode(*I); - } - - bool isNodeHidden(NodeType &Node) { - return isNodeHidden(&Node); + if (!isNodeHidden(&*I)) + writeNode(&*I); } - bool isNodeHidden(NodeType *const *Node) { + bool isNodeHidden(NodeRef const *Node) { return isNodeHidden(*Node); } - bool isNodeHidden(NodeType *Node) { + bool isNodeHidden(NodeRef Node) { return DTraits.isNodeHidden(Node); } - void writeNode(NodeType& Node) { - writeNode(&Node); - } - - void writeNode(NodeType *const *Node) { + void writeNode(NodeRef const *Node) { writeNode(*Node); } - void writeNode(NodeType *Node) { + void writeNode(NodeRef Node) { std::string NodeAttributes = DTraits.getNodeAttributes(Node, G); O << "\tNode" << static_cast(Node) << " [shape=record,"; @@ -237,8 +234,8 @@ writeEdge(Node, 64, EI); } - void writeEdge(NodeType *Node, unsigned edgeidx, child_iterator EI) { - if (NodeType *TargetNode = *EI) { + void writeEdge(NodeRef Node, unsigned edgeidx, child_iterator EI) { + if (NodeRef TargetNode = *EI) { int DestPort = -1; if (DTraits.edgeTargetsEdgeSource(Node, EI)) { child_iterator TargetIt = DTraits.getEdgeTarget(Node, EI); Index: llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp =================================================================== --- llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp +++ llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp @@ -61,6 +61,7 @@ template <> struct GraphTraits { typedef const BasicBlock NodeType; + typedef const BasicBlock *NodeRef; typedef succ_const_iterator ChildIteratorType; typedef Function::const_iterator nodes_iterator; Index: llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp =================================================================== --- llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp +++ llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp @@ -53,6 +53,7 @@ template <> struct GraphTraits { typedef const MachineBasicBlock NodeType; + typedef const MachineBasicBlock *NodeRef; typedef MachineBasicBlock::const_succ_iterator ChildIteratorType; typedef MachineFunction::const_iterator nodes_iterator;