This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] Simple out of ssa diagnostics


Heres a first cut at some simple reporting from SSA->normal. When there
is a variable live on entry which has a DEF in the program, a warning
will be issued. These are typically optimization mistakes. I could make
it an abort(), but there may be other useful things spit out later, so
I'll just make it a warning for now. 

I was going to make it complain about live-on-entry variables which
weren't PARM_DECLS as well, but it would issue the message for user
initiated use before defined cases and about a dozen testcases fail
because the error list doesn't match. Diego is about to give us a list
of "legitimate" or "expected" live on entry SSA_NAME versions. As soon
as that is available, I'll report anything not in that list which the
live range analysis finds.

I've also added another flag, "debug". I dont want to overwhelm DETAILS,
and I have bits of code that I am forever putting into my version of the
tree in order to figure out what out-of-ssa is doing wrong, or who the
culprit is. Initially here, its a CFG dump immediately before and after
the SSA->Normal phase. This makes reading the partition info more
sensible.  So I want to put those in under DEBUG control instead of
DETAIL. We can argue it, but I intended to spew out a lot of crud under
debug control.... Including the interfernce graph shortly.

Anyway, this bootstraps and passes all the tests. Hope someone finds
this first bit helpful.  more to come.


So you want me to check it in, or put it under DETAIL, or what.  

Oh, and I have no idea if I did the diagnostic bit right, but it works
for me on c , which is the only place I had a testcase producing the LOE
problem. :-)


Andrew



	* c-objc-common.c (c_tree_printer): Handle SSA_NAME variables.
	* tree-dump.c (dump_option_value_in): Add 'debug' tree option.
	* tree-ssa-live.c (calculate_live_on_entry): Warn against suspect live
	on entry variables.
	(rewrite_out_of_ssa): Add cfg dump before and after when debug is on.
	* tree.h (TDF_DEBUG): New option flag.


Index: c-objc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-objc-common.c,v
retrieving revision 1.14.2.13
diff -c -p -r1.14.2.13 c-objc-common.c
*** c-objc-common.c	7 May 2003 13:27:33 -0000	1.14.2.13
--- c-objc-common.c	12 Jun 2003 17:54:47 -0000
*************** c_tree_printer (buffer, text)
*** 442,451 ****
      case 'F':
      case 'T':
        {
!         const char *n = DECL_NAME (t)
!           ? (*lang_hooks.decl_printable_name) (t, 2)
!           : "({anonymous})";
!         output_add_string (buffer, n);
        }
        return true;
  
--- 442,456 ----
      case 'F':
      case 'T':
        {
! 	if (TREE_CODE (t) == SSA_NAME)
! 	  dump_generic_node (buffer, t, 0, 2);
! 	else
! 	  {
! 	    const char *n = DECL_NAME (t)
! 	      ? (*lang_hooks.decl_printable_name) (t, 2)
! 	      : "({anonymous})";
! 	    output_add_string (buffer, n);
! 	  }
        }
        return true;
  
Index: tree-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-dump.c,v
retrieving revision 1.6.2.27
diff -c -p -r1.6.2.27 tree-dump.c
*** tree-dump.c	11 Jun 2003 16:40:59 -0000	1.6.2.27
--- tree-dump.c	12 Jun 2003 17:54:48 -0000
*************** static const struct dump_option_value_in
*** 714,719 ****
--- 714,720 ----
    {"blocks", TDF_BLOCKS},
    {"alias", TDF_ALIAS},
    {"vops", TDF_VOPS},
+   {"debug", TDF_DEBUG},
    {"all", ~0},
    {NULL, 0}
  };
Index: tree-ssa-live.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-live.c,v
retrieving revision 1.1.2.7
diff -c -p -r1.1.2.7 tree-ssa-live.c
*** tree-ssa-live.c	11 Jun 2003 12:41:21 -0000	1.1.2.7
--- tree-ssa-live.c	12 Jun 2003 17:54:48 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 38,43 ****
--- 38,44 ----
  #include "hashtab.h"
  #include "tree-dump.h"
  #include "tree-ssa-live.h"
+ #include "errors.h"
  
  extern unsigned long next_ssa_version;
  
*************** calculate_live_on_entry (var_map map)
*** 545,550 ****
--- 546,578 ----
        live_worklist (live, stack, i);
      });
  
+ #ifdef ENABLE_CHECKING
+    /* Check for live on entry partitions and report those with a DEF in
+       the program. This will typically mean an optimization has done
+       something wrong.  */
+   for (i = 0; i < num_var_partitions (map); i++)
+     {
+       if (TEST_BIT (live_entry_blocks (live, i), 0))
+         {
+ 	  var = partition_to_var (map, i);
+ 	  if (!IS_EMPTY_STMT (SSA_NAME_DEF_STMT (var)))
+ 	    warning ("'%D' is defined, but is also live on entry.", var);
+ 	  else
+ 	    {
+ #if 0
+ /* FIXME. Disable until we can tell what is a "valid" user uninitialized
+    variable use and what isn't.  Otherwise we get a bunch of extra testcase
+    failures.  */
+ 	      /* Only PARM_DECLS should be live on entry right now.  */
+ 	      if (TREE_CODE (SSA_NAME_VAR (var)) != PARM_DECL)
+ 		warning ("'%D' is not a PARM_DECL, but is live on entry.", var);
+ #endif
+ 	      
+ 	    }
+ 	}
+     }
+   
+ #endif
    return live;
  }
  
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.91
diff -c -p -r1.1.4.91 tree-ssa.c
*** tree-ssa.c	11 Jun 2003 15:01:49 -0000	1.1.4.91
--- tree-ssa.c	12 Jun 2003 17:54:50 -0000
*************** rewrite_out_of_ssa (tree fndecl)
*** 1560,1565 ****
--- 1560,1568 ----
  
    tree_ssa_dump_file = dump_begin (TDI_optimized, &tree_ssa_dump_flags);
  
+   if (tree_ssa_dump_file && (tree_ssa_dump_flags & TDF_DEBUG))
+     dump_tree_cfg (tree_ssa_dump_file, tree_ssa_dump_flags & ~TDF_DETAILS);
+ 
    map = create_ssa_var_map ();
  
    /* Shrink the map to include only referenced variables.  Exclude variables
*************** rewrite_out_of_ssa (tree fndecl)
*** 1651,1656 ****
--- 1654,1662 ----
  
    /* If any copies were inserted on edges, actually insert them now.  */
    bsi_commit_edge_inserts (0, NULL);
+ 
+   if (tree_ssa_dump_file && (tree_ssa_dump_flags & TDF_DEBUG))
+     dump_tree_cfg (tree_ssa_dump_file, tree_ssa_dump_flags & ~TDF_DETAILS);
  
    /* Do some cleanups which reduce the amount of data the
       tree->rtl expanders deal with.  */
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.342.2.68
diff -c -p -r1.342.2.68 tree.h
*** tree.h	11 Jun 2003 16:40:59 -0000	1.342.2.68
--- tree.h	12 Jun 2003 17:54:51 -0000
*************** enum tree_dump_index
*** 3376,3381 ****
--- 3376,3382 ----
  #define TDF_BLOCKS	(1 << 5)	/* display basic block boundaries */
  #define TDF_ALIAS	(1 << 6)	/* display aliasing information */
  #define TDF_VOPS	(1 << 7)	/* display virtual operands */
+ #define TDF_DEBUG	((1 << 8) | TDF_DETAILS) /* display debug output */
  
  
  typedef struct dump_info *dump_info_p;




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]