Commits

Armin Rigo committed eb5983d

Fixes the test, but maybe makes things slower.
(transplanted from 3fb0e6c27959e20cb2b71acebaea47846f24fa86)

  • Participants
  • Parent commits 85f4226
  • Branches release-2.0.x

Comments (0)

Files changed (1)

rpython/translator/backendopt/graphanalyze.py

         self.graph_results = analyzer._analyzed_calls
         # the current stack of graphs being analyzed
         self.current_stack = []
-        self.current_stack_set = set()
+        #self.current_stack_set = set()
 
     def enter(self, graph):
         if graph not in self.graph_results:
             self.current_stack.append(graph)
-            self.current_stack_set.add(graph)
+            #self.current_stack_set.add(graph)
             self.graph_results.find(graph)
             return True
         else:
-            if graph in self.current_stack_set:
-                # found a cycle; merge all graphs in that cycle
-                i = len(self.current_stack) - 1
-                while self.current_stack[i] is not graph:
-                    self.graph_results.union(self.current_stack[i], graph)
-                    i -= 1
+            graph = self.graph_results.find_rep(graph)
+            for j in range(len(self.current_stack)):
+                othergraph = self.graph_results.find_rep(self.current_stack[j])
+                if graph is othergraph:
+                    # found a cycle; merge all graphs in that cycle
+                    for i in range(j, len(self.current_stack)):
+                        self.graph_results.union(self.current_stack[i], graph)
+                    # done
+                    break
             return False
 
     def leave_with(self, result):
         graph = self.current_stack.pop()
-        self.current_stack_set.remove(graph)
+        #self.current_stack_set.remove(graph)
         dep = self.graph_results[graph]
         dep.merge_with_result(result)