changeset 14946:3564bb141396

Only add items to worklist in type inferece if not already there
author Max Brister <max@2bass.com>
date Sat, 09 Jun 2012 10:23:28 -0500
parents 591aeec5c520
children d4bbe0ef7db5
files src/pt-jit.cc src/pt-jit.h
diffstat 2 files changed, 30 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/pt-jit.cc	Fri Jun 08 22:31:57 2012 -0500
+++ b/src/pt-jit.cc	Sat Jun 09 10:23:28 2012 -0500
@@ -1285,6 +1285,7 @@
     {
       jit_instruction *next = worklist.front ();
       worklist.pop_front ();
+      next->stash_in_worklist (false);
 
       if (next->infer ())
         {
@@ -1297,7 +1298,7 @@
     }
 
   remove_dead ();
-
+  merge_blocks ();
   place_releases ();
 
 #ifdef OCTAVE_JIT_DEBUG
@@ -1904,10 +1905,11 @@
           jit_block *succ = term->sucessor (i);
           for (jit_block::iterator iter = succ->begin (); iter != succ->end ()
                  && isa<jit_phi> (*iter); ++iter)
-            worklist.push_back (*iter);
-
-          if (succ->terminator ())
-            worklist.push_back (succ->terminator ());
+            push_worklist (*iter);
+
+          jit_terminator *sterm = succ->terminator ();
+          if (sterm)
+            push_worklist (sterm);
         }
     }
 }
--- a/src/pt-jit.h	Fri Jun 08 22:31:57 2012 -0500
+++ b/src/pt-jit.h	Sat Jun 09 10:23:28 2012 -0500
@@ -597,9 +597,20 @@
   friend class jit_use;
 public:
   jit_value (void) : llvm_value (0), ty (0), use_head (0), use_tail (0),
-                     myuse_count (0), mlast_use (0) {}
+                     myuse_count (0), mlast_use (0),
+		     min_worklist (false) {}
 
   virtual ~jit_value (void);
+  
+  bool in_worklist (void) const
+  {
+    return min_worklist;
+  }
+
+  void stash_in_worklist (bool ain_worklist)
+  {
+    min_worklist = ain_worklist;
+  }
 
   // replace all uses with
   void replace_with (jit_value *value);
@@ -674,6 +685,7 @@
   jit_use *use_tail;
   size_t myuse_count;
   jit_instruction *mlast_use;
+  bool min_worklist;
 };
 
 std::ostream& operator<< (std::ostream& os, const jit_value& value);
@@ -1928,10 +1940,19 @@
 
   jit_value *visit (tree& tee);
 
+  void push_worklist (jit_instruction *instr)
+  {
+    if (! instr->in_worklist ())
+      {
+	instr->stash_in_worklist (true);
+	worklist.push_back (instr);
+      }
+  }
+
   void append_users (jit_value *v)
   {
     for (jit_use *use = v->first_use (); use; use = use->next ())
-      worklist.push_back (use->user ());
+      push_worklist (use->user ());
   }
 
   void append_users_term (jit_terminator *term);