llvm.org GIT mirror llvm / aa8deed
[SelectionDAG] Pass DAG to checkForCycles Pass the DAG down to checkForCycles from all callers where we have it. This allows target-specific nodes to be printed properly. Also print some missing newlines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209976 91177308-0d34-0410-b5e6-96231b3b80d8 Adam Nemet 5 years ago
3 changed file(s) with 15 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
333333 assert((!N.getNode() || N.getValueType() == MVT::Other) &&
334334 "DAG root value is not a chain!");
335335 if (N.getNode())
336 checkForCycles(N.getNode());
336 checkForCycles(N.getNode(), this);
337337 Root = N;
338338 if (N.getNode())
339339 checkForCycles(this);
4848 template struct simplify_type;
4949 template struct ilist_traits;
5050
51 void checkForCycles(const SDNode *N);
51 void checkForCycles(const SDNode *N, const SelectionDAG *DAG = nullptr);
5252
5353 /// SDVTList - This represents a list of ValueType's that has been intern'd by
5454 /// a SelectionDAG. Instances of this simple value class are returned by
59555955 // count of outstanding operands.
59565956 for (allnodes_iterator I = allnodes_begin(),E = allnodes_end(); I != E; ) {
59575957 SDNode *N = I++;
5958 checkForCycles(N);
5958 checkForCycles(N, this);
59595959 unsigned Degree = N->getNumOperands();
59605960 if (Degree == 0) {
59615961 // A node with no uses, add it to the result array immediately.
59755975 // such that by the time the end is reached all nodes will be sorted.
59765976 for (allnodes_iterator I = allnodes_begin(),E = allnodes_end(); I != E; ++I) {
59775977 SDNode *N = I;
5978 checkForCycles(N);
5978 checkForCycles(N, this);
59795979 // N is in sorted position, so all its uses have one less operand
59805980 // that needs to be sorted.
59815981 for (SDNode::use_iterator UI = N->use_begin(), UE = N->use_end();
60006000 #ifndef NDEBUG
60016001 SDNode *S = ++I;
60026002 dbgs() << "Overran sorted position:\n";
6003 S->dumprFull();
6003 S->dumprFull(this); dbgs() << "\n";
60046004 #endif
60056005 llvm_unreachable(nullptr);
60066006 }
65896589 #ifdef XDEBUG
65906590 static void checkForCyclesHelper(const SDNode *N,
65916591 SmallPtrSet &Visited,
6592 SmallPtrSet &Checked) {
6592 SmallPtrSet &Checked,
6593 const llvm::SelectionDAG *DAG) {
65936594 // If this node has already been checked, don't check it again.
65946595 if (Checked.count(N))
65956596 return;
65976598 // If a node has already been visited on this depth-first walk, reject it as
65986599 // a cycle.
65996600 if (!Visited.insert(N)) {
6601 errs() << "Detected cycle in SelectionDAG\n";
66006602 dbgs() << "Offending node:\n";
6601 N->dumprFull();
6602 errs() << "Detected cycle in SelectionDAG\n";
6603 N->dumprFull(DAG); dbgs() << "\n";
66036604 abort();
66046605 }
66056606
66066607 for(unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
6607 checkForCyclesHelper(N->getOperand(i).getNode(), Visited, Checked);
6608 checkForCyclesHelper(N->getOperand(i).getNode(), Visited, Checked, DAG);
66086609
66096610 Checked.insert(N);
66106611 Visited.erase(N);
66116612 }
66126613 #endif
66136614
6614 void llvm::checkForCycles(const llvm::SDNode *N) {
6615 void llvm::checkForCycles(const llvm::SDNode *N,
6616 const llvm::SelectionDAG *DAG) {
66156617 #ifdef XDEBUG
66166618 assert(N && "Checking nonexistent SDNode");
66176619 SmallPtrSet visited;
66186620 SmallPtrSet checked;
6619 checkForCyclesHelper(N, visited, checked);
6621 checkForCyclesHelper(N, visited, checked, DAG);
66206622 #endif
66216623 }
66226624
66236625 void llvm::checkForCycles(const llvm::SelectionDAG *DAG) {
6624 checkForCycles(DAG->getRoot().getNode());
6625 }
6626 checkForCycles(DAG->getRoot().getNode(), DAG);
6627 }