[llvm-commits] [llvm] r96956 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

David Greene greened at obbligato.org
Tue Feb 23 09:37:50 PST 2010


Author: greened
Date: Tue Feb 23 11:37:50 2010
New Revision: 96956

URL: http://llvm.org/viewvc/llvm-project?rev=96956&view=rev
Log:

Speed up cycle checking significantly by caching results.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=96956&r1=96955&r2=96956&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Feb 23 11:37:50 2010
@@ -6315,7 +6315,11 @@
 }
 
 static void checkForCyclesHelper(const SDNode *N,
-                                 std::set<const SDNode *> &visited) {
+                                 std::set<const SDNode *> &visited,
+                                 std::set<const SDNode *> &checked) {
+  if (checked.find(N) != checked.end())
+    return;
+
   if (visited.find(N) != visited.end()) {
     dbgs() << "Offending node:\n";
     N->dumprFull();
@@ -6329,16 +6333,18 @@
   assert(inserted && "Missed cycle");
 
   for(unsigned i = 0; i < N->getNumOperands(); ++i) {
-    checkForCyclesHelper(N->getOperand(i).getNode(), visited);
+    checkForCyclesHelper(N->getOperand(i).getNode(), visited, checked);
   }
   visited.erase(i);
+  checked.insert(N);
 }
 
 void llvm::checkForCycles(const llvm::SDNode *N) {
 #ifdef XDEBUG
   assert(N && "Checking nonexistant SDNode");
   std::set<const SDNode *> visited;
-  checkForCyclesHelper(N, visited);
+  std::set<const SDNode *> checked;
+  checkForCyclesHelper(N, visited, checked);
 #endif
 }
 





More information about the llvm-commits mailing list