changeset 15602:f3e339aee38f

Fix block labeling in JIT debug output * jit-ir.cc (jit_block_list::label): New function. (jit_block::label, jit_block::print): Implementation moved to cc file. * jit-ir.h (jit_block_list::label): New function delcaration. (jit_block::label, jit_block::print): Implementation moved to cc file. (jit_block::print): Make it clear when a block has not been labeled. * pt-jit.cc (jit_inter::inter, jit_infer::construct_ssa, jit_function_info::jit_function_info, jit_info::compile): Use jit_block_list::label.
author Max Brister <max@2bass.com>
date Sun, 04 Nov 2012 20:09:23 -0700
parents 35bc8f16538f
children 44272909d926
files libinterp/interp-core/jit-ir.cc libinterp/interp-core/jit-ir.h libinterp/interp-core/pt-jit.cc
diffstat 3 files changed, 57 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/interp-core/jit-ir.cc	Mon Nov 05 01:48:23 2012 +0000
+++ b/libinterp/interp-core/jit-ir.cc	Sun Nov 04 20:09:23 2012 -0700
@@ -80,6 +80,16 @@
   insert_before (loc->location (), ablock);
 }
 
+void
+jit_block_list::label (void)
+{
+  if (mlist.size ())
+    {
+      jit_block *block = mlist.back ();
+      block->label ();
+    }
+}
+
 std::ostream&
 jit_block_list::print (std::ostream& os, const std::string& header) const
 {
@@ -469,6 +479,21 @@
 }
 
 void
+jit_block::label (size_t avisit_count, size_t& number)
+{
+  if (visited (avisit_count))
+    return;
+
+  for (jit_use *use = first_use (); use; use = use->next ())
+    {
+      jit_block *pred = use->user_parent ();
+      pred->label (avisit_count, number);
+    }
+
+  mid = number++;
+}
+
+void
 jit_block::pop_all (void)
 {
   for (iterator iter = begin (); iter != end (); ++iter)
@@ -478,6 +503,28 @@
     }
 }
 
+std::ostream&
+jit_block::print (std::ostream& os, size_t indent) const
+{
+  print_indent (os, indent);
+  short_print (os) << ":        %pred = ";
+  for (jit_use *use = first_use (); use; use = use->next ())
+    {
+      jit_block *pred = use->user_parent ();
+      os << *pred;
+      if (use->next ())
+        os << ", ";
+    }
+  os << std::endl;
+
+  for (const_iterator iter = begin (); iter != end (); ++iter)
+    {
+      jit_instruction *instr = *iter;
+      instr->print (os, indent + 1) << std::endl;
+    }
+  return os;
+}
+
 jit_block *
 jit_block::maybe_split (jit_factory& factory, jit_block_list& blocks,
                         jit_block *asuccessor)
--- a/libinterp/interp-core/jit-ir.h	Mon Nov 05 01:48:23 2012 +0000
+++ b/libinterp/interp-core/jit-ir.h	Sun Nov 04 20:09:23 2012 -0700
@@ -169,6 +169,8 @@
 
   void insert_before (jit_block *loc, jit_block *ablock);
 
+  void label (void);
+
   std::ostream& print (std::ostream& os, const std::string& header) const;
 
   std::ostream& print_dom (std::ostream& os) const;
@@ -654,19 +656,7 @@
     label (mvisit_count, number);
   }
 
-  void label (size_t avisit_count, size_t& number)
-  {
-    if (visited (avisit_count))
-      return;
-
-    for (jit_use *use = first_use (); use; use = use->next ())
-      {
-        jit_block *pred = use->user_parent ();
-        pred->label (avisit_count, number);
-      }
-
-    mid = number++;
-  }
+  void label (size_t avisit_count, size_t& number);
 
   // See for idom computation algorithm
   // Cooper, Keith D.; Harvey, Timothy J; and Kennedy, Ken (2001).
@@ -704,26 +694,7 @@
   // call pop_varaible on all instructions
   void pop_all (void);
 
-  virtual std::ostream& print (std::ostream& os, size_t indent = 0) const
-  {
-    print_indent (os, indent);
-    short_print (os) << ":        %pred = ";
-    for (jit_use *use = first_use (); use; use = use->next ())
-      {
-        jit_block *pred = use->user_parent ();
-        os << *pred;
-        if (use->next ())
-          os << ", ";
-      }
-    os << std::endl;
-
-    for (const_iterator iter = begin (); iter != end (); ++iter)
-      {
-        jit_instruction *instr = *iter;
-        instr->print (os, indent + 1) << std::endl;
-      }
-    return os;
-  }
+  virtual std::ostream& print (std::ostream& os, size_t indent = 0) const;
 
   jit_block *maybe_split (jit_factory& factory, jit_block_list& blocks,
                           jit_block *asuccessor);
@@ -742,6 +713,8 @@
     os << mname;
     if (mid != NO_ID)
       os << mid;
+    else
+      os << "!";
     return os;
   }
 
--- a/libinterp/interp-core/pt-jit.cc	Mon Nov 05 01:48:23 2012 +0000
+++ b/libinterp/interp-core/pt-jit.cc	Sun Nov 04 20:09:23 2012 -0700
@@ -1441,7 +1441,7 @@
     }
 
   remove_dead ();
-  final_block ().label ();
+  blocks.label ();
   place_releases ();
   simplify_phi ();
 }
@@ -1475,7 +1475,7 @@
 void
 jit_infer::construct_ssa (void)
 {
-  final_block ().label ();
+  blocks.label ();
   final_block ().compute_idom (entry_block ());
   entry_block ().compute_df ();
   entry_block ().create_dom_tree ();
@@ -1966,8 +1966,7 @@
       if (Venable_jit_debugging)
         {
           jit_block_list& blocks = infer.get_blocks ();
-          jit_block *entry_block = blocks.front ();
-          entry_block->label ();
+          blocks.label ();
           std::cout << "-------------------- Compiling function ";
           std::cout << "--------------------\n";
 
@@ -2186,8 +2185,7 @@
       if (Venable_jit_debugging)
         {
           jit_block_list& blocks = infer.get_blocks ();
-          jit_block *entry_block = blocks.front ();
-          entry_block->label ();
+          blocks.label ();
           std::cout << "-------------------- Compiling tree --------------------\n";
           std::cout << tee.str_print_code () << std::endl;
           blocks.print (std::cout, "octave jit ir");