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]

fix 15454


As discussed in the PR, I make the static chain variable a PARM_DECL,
so that we assume the proper things about how it is initialized.  Since
this is not a real parameter, this requires doing a few things by hand,
but the result is less bad than scattering special cases elsewhere in
the optimizers.


r~



        PR 15454
        * tree-nested.c (get_chain_decl): Create a PARM_DECL by hand.
        * function.c (expand_function_start): Expand static_chain_decl by hand.
        * gimplify.c (create_tmp_var_name): Export.
        * tree-gimple.h (create_tmp_var_name): Declare.
        * gcc.c-torture/execute/20040520-1.c: New.

Index: gcc/function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.517
diff -c -p -d -r1.517 function.c
*** gcc/function.c	19 May 2004 17:53:45 -0000	1.517
--- gcc/function.c	20 May 2004 17:33:02 -0000
*************** expand_function_start (tree subr, int pa
*** 6565,6576 ****
    /* If function gets a static chain arg, store it.  */
    if (cfun->static_chain_decl)
      {
!       rtx x;
  
!       expand_var (cfun->static_chain_decl);
!       x = expand_expr (cfun->static_chain_decl, NULL_RTX,
! 		       VOIDmode, EXPAND_WRITE);
!       emit_move_insn (x, static_chain_incoming_rtx);
      }
  
    /* If the function receives a non-local goto, then store the
--- 6565,6579 ----
    /* If function gets a static chain arg, store it.  */
    if (cfun->static_chain_decl)
      {
!       tree parm = cfun->static_chain_decl;
!       rtx local = gen_reg_rtx (Pmode);
  
!       set_decl_incoming_rtl (parm, static_chain_incoming_rtx);
!       SET_DECL_RTL (parm, local);
!       maybe_set_unchanging (local, parm);
!       mark_reg_pointer (local, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm))));
! 
!       emit_move_insn (local, static_chain_incoming_rtx);
      }
  
    /* If the function receives a non-local goto, then store the
Index: gcc/gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v
retrieving revision 2.3
diff -c -p -d -r2.3 gimplify.c
*** gcc/gimplify.c	15 May 2004 23:07:50 -0000	2.3
--- gcc/gimplify.c	20 May 2004 17:33:02 -0000
*************** create_artificial_label (void)
*** 286,292 ****
  
  static GTY(()) unsigned int tmp_var_id_num;
  
! static tree
  create_tmp_var_name (const char *prefix)
  {
    char *tmp_name;
--- 286,292 ----
  
  static GTY(()) unsigned int tmp_var_id_num;
  
! tree
  create_tmp_var_name (const char *prefix)
  {
    char *tmp_name;
Index: gcc/tree-gimple.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-gimple.h,v
retrieving revision 2.1
diff -c -p -d -r2.1 tree-gimple.h
*** gcc/tree-gimple.h	14 May 2004 02:29:22 -0000	2.1
--- gcc/tree-gimple.h	20 May 2004 17:33:02 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 26,31 ****
--- 26,32 ----
  #include "tree-iterator.h"
  
  extern tree create_tmp_var_raw (tree, const char *);
+ extern tree create_tmp_var_name (const char *);
  extern tree create_tmp_var (tree, const char *);
  extern bool is_gimple_tmp_var (tree);
  extern tree get_initialized_tmp_var (tree, tree *, tree *);
Index: gcc/tree-nested.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-nested.c,v
retrieving revision 2.2
diff -c -p -d -r2.2 tree-nested.c
*** gcc/tree-nested.c	14 May 2004 02:29:22 -0000	2.2
--- gcc/tree-nested.c	20 May 2004 17:33:02 -0000
*************** get_chain_decl (struct nesting_info *inf
*** 306,320 ****
  
        /* Note that this variable is *not* entered into any BIND_EXPR;
  	 the construction of this variable is handled specially in
! 	 expand_function_start and initialize_inlined_parameters.  */
!       decl = create_tmp_var_raw (type, "CHAIN");
        DECL_CONTEXT (decl) = info->context;
!       decl->decl.seen_in_bind_expr = 1;
! 
!       /* The initialization of CHAIN is not visible to the tree-ssa
! 	 analyzers and optimizers.  Thus we do not want to issue
! 	 warnings for CHAIN.  */
!       TREE_NO_WARNING (decl) = 1;
  
        /* Tell tree-inline.c that we never write to this variable, so
  	 it can copy-prop the replacement value immediately.  */
--- 306,321 ----
  
        /* Note that this variable is *not* entered into any BIND_EXPR;
  	 the construction of this variable is handled specially in
! 	 expand_function_start and initialize_inlined_parameters.
! 	 Note also that it's represented as a parameter.  This is more
! 	 close to the truth, since the initial value does come from 
! 	 the caller.  */
!       decl = build_decl (PARM_DECL, create_tmp_var_name ("CHAIN"), type);
!       DECL_ARTIFICIAL (decl) = 1;
!       DECL_IGNORED_P (decl) = 1;
!       TREE_USED (decl) = 1;
        DECL_CONTEXT (decl) = info->context;
!       DECL_ARG_TYPE (decl) = type;
  
        /* Tell tree-inline.c that we never write to this variable, so
  	 it can copy-prop the replacement value immediately.  */
Index: gcc/testsuite/gcc.c-torture/execute/20040520-1.c
===================================================================
RCS file: gcc/testsuite/gcc.c-torture/execute/20040520-1.c
diff -N gcc/testsuite/gcc.c-torture/execute/20040520-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/gcc.c-torture/execute/20040520-1.c	20 May 2004 17:33:02 -0000
***************
*** 0 ****
--- 1,17 ----
+ /* PR 15454 */
+ 
+ void abort ();
+ int main () {
+         int foo;
+         int bar (void)
+         {
+                 int baz = 0;
+                 if (foo!=45)
+                         baz = foo;
+                 return baz;
+         }
+         foo = 1;
+         if (!bar ())
+                 abort ();
+         return 0;
+ }


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