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]

Fwd: [tree-ssa] Mark CALL_EXPRs volatile before aliasing


Diego has apparently been black-listed.  I'm sure overseers will
have it taken care of shortly...


r~


On Tue, Mar 02, 2004 at 08:18:42PM -0500, Diego Novillo wrote:
> 
> Post this for me?
> 
> Thanks.
> 
> -----Forwarded Message-----
> From: Diego Novillo <dnovillo@redhat.com>
> To: gcc-patches@gcc.gnu.org <gcc-patches@gcc.gnu.org>
> Subject: [tree-ssa] Mark CALL_EXPRs volatile before aliasing
> Date: Tue, 02 Mar 2004 20:13:28 -0500
> 
> 
> Fixes a latent bug for any pass that wants to deal with CALL_EXPRs
> before aliasing is computed.  Before aliasing, there are no
> call-clobbered variables.  Such a pass would think that function calls
> have no side-effects.  Fixed by marking CALL_EXPRs as having volatile
> operands.
> 
> I also needed to tweak some tree-ssa.exp tests that were checking too
> early.
> 
> Finally, I don't know why we weren't failing
> gcc.dg/tree-ssa/20030815-1.c before.  The tests expects 0 type casts,
> but we need at least 1 (to convert the input parameter from unsigned
> into struct rtx_def **).
> 
> Bootstrapped and tested x86, x86-64 and ia64.
> 
> 
> Diego.
> 
> 
> 	* tree-ssa-operands.c (get_expr_operands): Mark CALL_EXPRs
> 	with has_volatile_ops if aliases haven't been computed yet.
> 	(add_stmt_operand): Use 'true' instead of '1'.
> 
> testsuite/ChangeLog.tree-ssa:
> 
> 	* testsuite/gcc.dg/tree-ssa/20030815-1.c: Expect 1 type cast.
> 	* testsuite/gcc.dg/tree-ssa/ssa-dce-1.c: Check after aliasing.
> 	* testsuite/gcc.dg/tree-ssa/ssa-dce-2.c: Likewise.
> 	* testsuite/gcc.dg/tree-ssa/ssa-dom-cse-1.c: Likewise.
> 
> Index: tree-ssa-operands.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-operands.c,v
> retrieving revision 1.1.2.13
> diff -d -c -p -r1.1.2.13 tree-ssa-operands.c
> *** tree-ssa-operands.c	28 Feb 2004 01:06:20 -0000	1.1.2.13
> --- tree-ssa-operands.c	3 Mar 2004 00:58:31 -0000
> *************** get_expr_operands (tree stmt, tree *expr
> *** 1052,1057 ****
> --- 1052,1059 ----
>   	  else if (!(call_flags & (ECF_CONST | ECF_NORETURN)))
>   	    add_call_read_ops (stmt, prev_vops);
>   	}
> +       else if (!aliases_computed_p)
> + 	stmt_ann (stmt)->has_volatile_ops = true;
>   
>         return;
>       }
> *************** add_stmt_operand (tree *var_p, tree stmt
> *** 1165,1178 ****
>        the statement as having volatile operands and return.  */
>     if (v_ann->has_hidden_use)
>       {
> !       s_ann->has_volatile_ops = 1;
>         return;
>       }
>   
>     /* Don't expose volatile variables to the optimizers.  */
>     if (TREE_THIS_VOLATILE (sym))
>       {
> !       s_ann->has_volatile_ops = 1;
>         return;
>       }
>   
> --- 1167,1180 ----
>        the statement as having volatile operands and return.  */
>     if (v_ann->has_hidden_use)
>       {
> !       s_ann->has_volatile_ops = true;
>         return;
>       }
>   
>     /* Don't expose volatile variables to the optimizers.  */
>     if (TREE_THIS_VOLATILE (sym))
>       {
> !       s_ann->has_volatile_ops = true;
>         return;
>       }
>   
> *************** add_stmt_operand (tree *var_p, tree stmt
> *** 1203,1209 ****
>   	 and return.  */
>         if (!aliases_computed_p && may_be_aliased (var))
>   	{
> ! 	  s_ann->has_volatile_ops = 1;
>   	  return;
>   	}
>   
> --- 1205,1211 ----
>   	 and return.  */
>         if (!aliases_computed_p && may_be_aliased (var))
>   	{
> ! 	  s_ann->has_volatile_ops = true;
>   	  return;
>   	}
>   
> 
> Index: testsuite/gcc.dg/tree-ssa/20030815-1.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/Attic/20030815-1.c,v
> retrieving revision 1.1.2.3
> diff -d -c -p -r1.1.2.3 20030815-1.c
> *** testsuite/gcc.dg/tree-ssa/20030815-1.c	7 Jan 2004 23:44:17 -0000	1.1.2.3
> --- testsuite/gcc.dg/tree-ssa/20030815-1.c	3 Mar 2004 01:01:11 -0000
> *************** blah (unsigned int regno)
> *** 34,41 ****
>       return reg_base_value[regno];
>   }
>   
> ! /* If we have a cast to a struct rtx_def * *, then we failed to
> !    eliminate some useless typecasting.  */
> ! /* { dg-final { scan-tree-dump-times "\\(struct rtx_def \\* \\*\\)" 0 "dom3"} } */
>                                                                                   
>   
> --- 34,42 ----
>       return reg_base_value[regno];
>   }
>   
> ! /* If we have more than 1 cast to a struct rtx_def * *, then we failed to
> !    eliminate some useless typecasting.  The first type cast is needed
> !    to convert the unsigned int regno parameter into a struct rtx_def **.  */
> ! /* { dg-final { scan-tree-dump-times "\\(struct rtx_def \\* \\*\\)" 1 "dom3"} } */
>                                                                                   
>   
> Index: testsuite/gcc.dg/tree-ssa/ssa-dce-1.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/Attic/ssa-dce-1.c,v
> retrieving revision 1.1.2.1
> diff -d -c -p -r1.1.2.1 ssa-dce-1.c
> *** testsuite/gcc.dg/tree-ssa/ssa-dce-1.c	13 Nov 2003 03:00:41 -0000	1.1.2.1
> --- testsuite/gcc.dg/tree-ssa/ssa-dce-1.c	3 Mar 2004 01:01:11 -0000
> ***************
> *** 1,5 ****
>   /* { dg-do compile } */
> ! /* { dg-options "-O1 -fdump-tree-dce1" } */
>   
>   int t() __attribute__ ((const));
>   q()
> --- 1,5 ----
>   /* { dg-do compile } */
> ! /* { dg-options "-O1 -fdump-tree-dce3" } */
>   
>   int t() __attribute__ ((const));
>   q()
> *************** q()
> *** 9,12 ****
>       i = t();
>   }
>   /* There should be no IF conditionals.  */
> ! /* { dg-final { scan-tree-dump-times "if " 0 "dce1"} } */
> --- 9,12 ----
>       i = t();
>   }
>   /* There should be no IF conditionals.  */
> ! /* { dg-final { scan-tree-dump-times "if " 0 "dce3"} } */
> Index: testsuite/gcc.dg/tree-ssa/ssa-dce-2.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/Attic/ssa-dce-2.c,v
> retrieving revision 1.1.2.1
> diff -d -c -p -r1.1.2.1 ssa-dce-2.c
> *** testsuite/gcc.dg/tree-ssa/ssa-dce-2.c	13 Nov 2003 03:00:41 -0000	1.1.2.1
> --- testsuite/gcc.dg/tree-ssa/ssa-dce-2.c	3 Mar 2004 01:01:11 -0000
> ***************
> *** 1,5 ****
>   /* { dg-do compile } */
> ! /* { dg-options "-O1 -fdump-tree-dce1" } */
>   
>   /* We should notice constantness of this function. */
>   int t(int a) 
> --- 1,5 ----
>   /* { dg-do compile } */
> ! /* { dg-options "-O1 -fdump-tree-dce3" } */
>   
>   /* We should notice constantness of this function. */
>   int t(int a) 
> *************** q()
> *** 13,16 ****
>       i = t(1);
>   }
>   /* There should be no IF conditionals.  */
> ! /* { dg-final { scan-tree-dump-times "if " 0 "dce1"} } */
> --- 13,16 ----
>       i = t(1);
>   }
>   /* There should be no IF conditionals.  */
> ! /* { dg-final { scan-tree-dump-times "if " 0 "dce3"} } */
> Index: testsuite/gcc.dg/tree-ssa/ssa-dom-cse-1.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/tree-ssa/Attic/ssa-dom-cse-1.c,v
> retrieving revision 1.1.2.1
> diff -d -c -p -r1.1.2.1 ssa-dom-cse-1.c
> *** testsuite/gcc.dg/tree-ssa/ssa-dom-cse-1.c	13 Nov 2003 02:32:27 -0000	1.1.2.1
> --- testsuite/gcc.dg/tree-ssa/ssa-dom-cse-1.c	3 Mar 2004 01:01:11 -0000
> ***************
> *** 1,5 ****
>   /* { dg-do compile } */ 
> ! /* { dg-options "-O2 -fdump-tree-dom1-details" } */
>   int t(int a) __attribute__ ((const));
>   void q (void);
>   void
> --- 1,5 ----
>   /* { dg-do compile } */ 
> ! /* { dg-options "-O2 -fdump-tree-dom2-details" } */
>   int t(int a) __attribute__ ((const));
>   void q (void);
>   void
> *************** threading(int a,int b)
> *** 11,15 ****
>   	    q();
>   	}
>   }
> ! /* We should thread the jump twice and elliminate it.  */
> ! /* { dg-final { scan-tree-dump-times "Replaced.* t " 1 "dom1"} } */
> --- 11,16 ----
>   	    q();
>   	}
>   }
> ! /* We should thread the jump twice and eliminate it.  Test this in
> !    DOM2, after aliases have been computed.  */
> ! /* { dg-final { scan-tree-dump-times "Replaced.* t " 1 "dom2"} } */
> 


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