[tcb] Do not create .GLOBAL_VAR if there are no call-clobbered vars

Diego Novillo dnovillo@redhat.com
Fri Oct 15 03:44:00 GMT 2004


We were creating .GLOBAL_VAR to work around the problem of TER
recombining function calls when there wasn't a dataflow dependency
between the two:

x_5 = foo ();
...
bar (x_5);

when going out of SSA, the expression recombiner would convert the above
into

...
bar (foo ());

If foo() has other side-effects, moving it after '...' may be wrong.  We
used to create .GLOBAL_VAR to create a fake dependency between the calls
to foo and bar.  This is unnecessary and creates more symbols that may
create unneeded alias relationships.  We really only need to stop
recombining the calls.

Bootstrapped and tested x86, x86-64 and ppc.


Diego.

2004-10-14  Diego Novillo  <dnovillo@redhat.com>

	* tree-outof-ssa.c (check_replaceable): Return false for
	calls with side-effects.


Index: tree-outof-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-outof-ssa.c,v
retrieving revision 2.22.2.3
diff -d -c -p -r2.22.2.3 tree-outof-ssa.c
*** tree-outof-ssa.c	13 Oct 2004 16:04:15 -0000	2.22.2.3
--- tree-outof-ssa.c	15 Oct 2004 00:47:38 -0000
*************** check_replaceable (temp_expr_table_p tab
*** 1462,1467 ****
--- 1462,1468 ----
    int num_use_ops, version;
    var_map map = tab->map;
    ssa_op_iter iter;
+   tree call_expr;
  
    if (TREE_CODE (stmt) != MODIFY_EXPR)
      return false;
*************** check_replaceable (temp_expr_table_p tab
*** 1488,1493 ****
--- 1489,1503 ----
    if (flag_float_store && FLOAT_TYPE_P (TREE_TYPE (TREE_OPERAND (stmt, 1))))
      return false;
  
+   /* Calls to functions with side-effects cannot be replaced.  */
+   if ((call_expr = get_call_expr_in (stmt)) != NULL_TREE)
+     {
+       int call_flags = call_expr_flags (call_expr);
+       if (TREE_SIDE_EFFECTS (call_expr)
+ 	  && !(call_flags & (ECF_PURE | ECF_CONST | ECF_NORETURN)))
+ 	return false;
+     }
+ 
    uses = USE_OPS (ann);
    num_use_ops = NUM_USES (uses);
    vuseops = VUSE_OPS (ann);




More information about the Gcc-patches mailing list