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] alloca/setjmp discovery take II


Hi,
the earlier patch has problem that flags_from_decl_or_type didn't set
ECF_MAY_BE_ALLOCA.  It seems to be somewhat confusing that certain flags
needs different function, so it looks it is best to simply modify it.

Honza

Regtested/bootstrapped i386 together with tailcall patch.  OK?

	* calls.c (flags_from_decl_or_type):  Use special_function_p.
	(expand_call): Remove call to special_function_p.
	* tree-cfg.c (notice_special_calls, clear_special_calls): New functions.
	(remove_useless_stmts): Use clear_special_calls.
	(remove_useless_stmts_1): Use notice_special_calls.
	* tree-flow.h (notice_special_calls, clear_special_calls): New functions.
	* tree-ssa-dce.c (remove_dead_stmts): Use clear_special_calls and
	notice_special_calls..
Index: calls.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/calls.c,v
retrieving revision 1.229.2.33
diff -c -3 -p -r1.229.2.33 calls.c
*** calls.c	18 Oct 2003 23:59:36 -0000	1.229.2.33
--- calls.c	12 Nov 2003 23:15:41 -0000
*************** flags_from_decl_or_type (tree exp)
*** 735,740 ****
--- 735,742 ----
  
        if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
  	flags |= ECF_LIBCALL_BLOCK;
+ 
+       flags = special_function_p (exp, flags);
      }
  
    if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
*************** expand_call (tree exp, rtx target, int i
*** 2308,2317 ****
    else
      type_arg_types = TYPE_ARG_TYPES (funtype);
  
-   /* See if this is a call to a function that can return more than once
-      or a call to longjmp or malloc.  */
-   flags |= special_function_p (fndecl, flags);
- 
    if (flags & ECF_MAY_BE_ALLOCA)
      current_function_calls_alloca = 1;
  
--- 2369,2374 ----
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.208
diff -c -3 -p -r1.1.4.208 tree-cfg.c
*** tree-cfg.c	12 Nov 2003 15:09:11 -0000	1.1.4.208
--- tree-cfg.c	12 Nov 2003 23:17:03 -0000
*************** clear_blocks_annotations (void)
*** 381,386 ****
--- 382,408 ----
      bb->tree_annotations = NULL;
  }
  
+ /* t is CALL_EXPR.  Set current_function_calls_* flags.  */
+ void
+ notice_special_calls (tree t)
+ {
+   int flags = call_expr_flags (t);
+ 
+   if (flags & ECF_MAY_BE_ALLOCA)
+     current_function_calls_alloca = true;
+   if (flags & ECF_RETURNS_TWICE)
+     current_function_calls_setjmp = true;
+ }
+ 
+ /* Clear flags set by notice_special_calls.  Used by dead code removal
+    to update the flags.  */
+ void
+ clear_special_calls (void)
+ {
+   current_function_calls_alloca = false;
+   current_function_calls_setjmp = false;
+ }
+ 
  /* Build a flowgraph for the statements starting at the statement pointed
     by FIRST_P.
  
*************** remove_useless_stmts_1 (tree *first_p, s
*** 1244,1256 ****
  	  data->may_branch = true;
  	  break;
  	case CALL_EXPR:
  	  update_call_expr_flags (*stmt_p);
  	  if (tree_could_throw_p (*stmt_p))
  	    data->may_throw = true;
  	  break;
  	case MODIFY_EXPR:
  	  if (TREE_CODE (TREE_OPERAND (*stmt_p, 1)) == CALL_EXPR)
! 	    update_call_expr_flags (TREE_OPERAND (*stmt_p, 1));
  	  if (tree_could_throw_p (*stmt_p))
  	    data->may_throw = true;
  	  break;
--- 1266,1282 ----
  	  data->may_branch = true;
  	  break;
  	case CALL_EXPR:
+ 	  notice_special_calls (*stmt_p);
  	  update_call_expr_flags (*stmt_p);
  	  if (tree_could_throw_p (*stmt_p))
  	    data->may_throw = true;
  	  break;
  	case MODIFY_EXPR:
  	  if (TREE_CODE (TREE_OPERAND (*stmt_p, 1)) == CALL_EXPR)
! 	    {
! 	      update_call_expr_flags (TREE_OPERAND (*stmt_p, 1));
! 	      notice_special_calls (TREE_OPERAND (*stmt_p, 1));
! 	    }
  	  if (tree_could_throw_p (*stmt_p))
  	    data->may_throw = true;
  	  break;
*************** void
*** 1270,1275 ****
--- 1296,1304 ----
  remove_useless_stmts (tree *first_p)
  {
    struct rus_data data;
+ 
+   clear_special_calls ();
+ 
    do
      {
        memset (&data, 0, sizeof (data));
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.145
diff -c -3 -p -r1.1.4.145 tree-flow.h
*** tree-flow.h	12 Nov 2003 15:09:11 -0000	1.1.4.145
--- tree-flow.h	12 Nov 2003 23:17:07 -0000
*************** extern edge thread_edge (edge, basic_blo
*** 459,466 ****
  extern basic_block label_to_block (tree);
  extern bool cleanup_cond_expr_graph (basic_block, block_stmt_iterator);
  extern bool cleanup_switch_expr_graph (basic_block, block_stmt_iterator);
  extern void tree_optimize_tail_calls (void);
  extern basic_block tree_block_forwards_to (basic_block bb);
  
  /* In tree-pretty-print.c.  */
  extern void dump_generic_bb (FILE *, basic_block, int, int);
--- 459,468 ----
  extern basic_block label_to_block (tree);
  extern bool cleanup_cond_expr_graph (basic_block, block_stmt_iterator);
  extern bool cleanup_switch_expr_graph (basic_block, block_stmt_iterator);
  extern void tree_optimize_tail_calls (void);
  extern basic_block tree_block_forwards_to (basic_block bb);
+ extern void notice_special_calls (tree);
+ extern void clear_special_calls (void);
  
  /* In tree-pretty-print.c.  */
  extern void dump_generic_bb (FILE *, basic_block, int, int);
Index: tree-ssa-dce.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dce.c,v
retrieving revision 1.1.2.66
diff -c -3 -p -r1.1.2.66 tree-ssa-dce.c
*** tree-ssa-dce.c	11 Nov 2003 21:08:02 -0000	1.1.2.66
--- tree-ssa-dce.c	12 Nov 2003 23:17:11 -0000
*************** remove_dead_stmts (void)
*** 396,401 ****
--- 396,402 ----
    tree t;
    block_stmt_iterator i;
  
+   clear_special_calls ();
    FOR_EACH_BB_REVERSE (bb)
      {
        bsi_list_p stack;
*************** remove_dead_stmts (void)
*** 411,416 ****
--- 412,422 ----
  	  /* If `i' is not in `necessary' then remove from B.  */
  	  if (!necessary_p (t))
  	    remove_dead_stmt (&i);
+ 	  else if (TREE_CODE (t) == CALL_EXPR)
+ 	    notice_special_calls (t);
+ 	  else if (TREE_CODE (t) == MODIFY_EXPR
+ 		   && TREE_CODE (TREE_OPERAND (t, 1)) == CALL_EXPR)
+ 	    notice_special_calls (TREE_OPERAND (t, 1));
  	}
      }
  }


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