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] More housecleaning


Inlining C++ code can often create naked RESULT_DECLs -- ie, they're
statements by themselves.

Gimple doesn't allow that, and in fact, a naked _DECL can potentially
result in incorrect code.

This patch fixes the inlininer to not create naked RESULT_DECLs.

Bootstrapped and regression tested.

	* gimplify.c (keep_function_tree_in_gimple_form): Move check of
	flag_disable_simple here.  Include flags.h.
	* Makefile.in (gimplify.o): Depends on flags.h
	* c-decl.c (c_expand_body_1): No longer check flag_disable_simple.
	* tree-inline.c (copy_body_r): Avoid creating non-gimple code
	when inlining a function where the RESULT_DECL's initialization
	is not on the RETURN_EXPR.

	* cp/optimize.c (optimize_function): No longer check
	flag_disable_simple.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.903.2.83
diff -c -3 -p -r1.903.2.83 Makefile.in
*** Makefile.in	9 Apr 2003 19:27:15 -0000	1.903.2.83
--- Makefile.in	15 Apr 2003 21:52:23 -0000
*************** tree-ssa-pre.o : tree-ssa-pre.c $(TREE_F
*** 1524,1530 ****
  tree-cfg.o : tree-cfg.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
     $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) flags.h output.h \
     diagnostic.h errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h \
!    $(TREE_DUMP_H)
  tree-dfa.o : tree-dfa.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
     $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \
     errors.h tree-inline.h $(HASHTAB_H) flags.h function.h $(TIMEVAR_H) \
--- 1524,1530 ----
  tree-cfg.o : tree-cfg.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
     $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) flags.h output.h \
     diagnostic.h errors.h function.h $(TIMEVAR_H) $(TM_H) coretypes.h \
!    $(TREE_DUMP_H) except.h
  tree-dfa.o : tree-dfa.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
     $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \
     errors.h tree-inline.h $(HASHTAB_H) flags.h function.h $(TIMEVAR_H) \
*************** c-simplify.o : c-simplify.c $(CONFIG_H) 
*** 1539,1545 ****
     $(TM_H) coretypes.h
  gimplify.o : gimplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) errors.h \
     diagnostic.h $(TREE_SIMPLE_H) tree-inline.h varray.h langhooks.h \
!    langhooks-def.h $(TREE_FLOW_H) $(TIMEVAR_H) $(TM_H) coretypes.h except.h
  tree-browser.o : tree-browser.c tree-browser.def $(CONFIG_H) $(SYSTEM_H) \
     $(TREE_H) errors.h tree-inline.h diagnostic.h $(HASHTAB_H) \
     $(TM_H) coretypes.h
--- 1539,1546 ----
     $(TM_H) coretypes.h
  gimplify.o : gimplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) errors.h \
     diagnostic.h $(TREE_SIMPLE_H) tree-inline.h varray.h langhooks.h \
!    langhooks-def.h $(TREE_FLOW_H) $(TIMEVAR_H) $(TM_H) coretypes.h except.h \
!    flags.h
  tree-browser.o : tree-browser.c tree-browser.def $(CONFIG_H) $(SYSTEM_H) \
     $(TREE_H) errors.h tree-inline.h diagnostic.h $(HASHTAB_H) \
     $(TM_H) coretypes.h
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/gimplify.c,v
retrieving revision 1.1.2.33
diff -c -3 -p -r1.1.2.33 gimplify.c
*** gimplify.c	9 Apr 2003 19:27:33 -0000	1.1.2.33
--- gimplify.c	15 Apr 2003 21:52:42 -0000
*************** Software Foundation, 59 Temple Place - S
*** 37,42 ****
--- 37,43 ----
  #include "tree-flow.h"
  #include "timevar.h"
  #include "except.h"
+ #include "flags.h"
  
  static void simplify_constructor     PARAMS ((tree, tree *, tree *));
  static void simplify_array_ref       PARAMS ((tree *, tree *, tree *));
*************** keep_function_tree_in_gimple_form (fndec
*** 163,168 ****
--- 164,173 ----
       tree fndecl;
  {
    tree fnbody;
+ 
+   /* If we were asked explicitly not to use gimple form, then return zero.  
*/
+   if (flag_disable_simple)
+     return 0;
  
    /* If the program has had errors, then keeping gimple form is not
       necessary.  */
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.334.2.42
diff -c -3 -p -r1.334.2.42 c-decl.c
*** c-decl.c	9 Apr 2003 19:27:18 -0000	1.334.2.42
--- c-decl.c	15 Apr 2003 21:52:57 -0000
*************** c_expand_body_1 (fndecl, nested_p)
*** 6588,6594 ****
  
    /* Simplify the function.  Don't try to optimize the function if
       simplification failed.  */
!   if (!flag_disable_simple && keep_function_tree_in_gimple_form (fndecl))
      {
        /* Debugging dump after simplification.  */
        dump_function (TDI_simple, fndecl);
--- 6588,6594 ----
  
    /* Simplify the function.  Don't try to optimize the function if
       simplification failed.  */
!   if (keep_function_tree_in_gimple_form (fndecl))
      {
        /* Debugging dump after simplification.  */
        dump_function (TDI_simple, fndecl);
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.26.2.25
diff -c -3 -p -r1.26.2.25 tree-inline.c
*** tree-inline.c	9 Apr 2003 19:27:40 -0000	1.26.2.25
--- tree-inline.c	15 Apr 2003 21:53:01 -0000
*************** copy_body_r (tp, walk_subtrees, data)
*** 359,364 ****
--- 359,369 ----
  	 RESULT_DECL.  */
        if (assignment)
          {
+ 	  /* Do not create a statement containing a naked RESULT_DECL.  */
+ 	  if (keep_function_tree_in_gimple_form (id->decl))
+ 	    if (TREE_CODE (assignment) == RESULT_DECL)
+ 	      simplify_stmt (&assignment);
+ 
  	  *tp = build (BIND_EXPR, void_type_node, NULL_TREE,
  		       build (COMPOUND_EXPR, void_type_node,
  			      assignment, goto_stmt),
Index: cp/optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/optimize.c,v
retrieving revision 1.81.10.16
diff -c -3 -p -r1.81.10.16 optimize.c
*** cp/optimize.c	9 Apr 2003 19:28:29 -0000	1.81.10.16
--- cp/optimize.c	15 Apr 2003 21:53:02 -0000
*************** optimize_function (tree fn)
*** 79,85 ****
  
    /* Simplify the function.  Don't try to optimize the function if
       simplification failed.  */
!   if (!flag_disable_simple && keep_function_tree_in_gimple_form (fn))
      {
        /* Debugging dump after simplification.  */
        dump_function (TDI_simple, fn);
--- 79,85 ----
  
    /* Simplify the function.  Don't try to optimize the function if
       simplification failed.  */
!   if (keep_function_tree_in_gimple_form (fn))
      {
        /* Debugging dump after simplification.  */
        dump_function (TDI_simple, fn);




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