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]

C++ PATCH to fix ADDRESSOF optimization


Since the switch to function-at-a-time processing, ADDRESSOF has been
broken, since assign_parms and expand_decl don't put TREE_ADDRESSABLE
decls into registers.  This patch fixes them to use put_var_into_stack
just as the old mark_addressable did.

I started to explore deferring the call to put_var_into_stack until
expand_expr time, but it turned out to be fairly complicated and I
decided that this tweak would hold us until we get scatter-gather
allocation of variables.

2000-11-11  Jason Merrill  <jason@redhat.com>

	* function.c (assign_parms): If TREE_ADDRESSABLE is set, try to 
	give the parm a register and then call put_var_into_stack.
	* stmt.c (expand_decl): Likewise.

cp/:
2000-11-11  Jason Merrill  <jason@redhat.com>

	* typeck.c (mark_addressable): Don't call put_var_into_stack.

*** function.c.~1~	Sat Nov 11 23:29:59 2000
--- function.c	Sat Nov 11 23:30:07 2000
*************** assign_parms (fndecl)
*** 4610,4617 ****
        else if (! ((! optimize
  		   && ! DECL_REGISTER (parm)
  		   && ! DECL_INLINE (fndecl))
- 		  /* layout_decl may set this.  */
- 		  || TREE_ADDRESSABLE (parm)
  		  || TREE_SIDE_EFFECTS (parm)
  		  /* If -ffloat-store specified, don't put explicit
  		     float variables into registers.  */
--- 4610,4615 ----
*************** assign_parms (fndecl)
*** 4695,4702 ****
  	      && ! ((! optimize
  		     && ! DECL_REGISTER (parm)
  		     && ! DECL_INLINE (fndecl))
- 		    /* layout_decl may set this.  */
- 		    || TREE_ADDRESSABLE (parm)
  		    || TREE_SIDE_EFFECTS (parm)
  		    /* If -ffloat-store specified, don't put explicit
  		       float variables into registers.  */
--- 4693,4698 ----
*************** assign_parms (fndecl)
*** 4865,4870 ****
--- 4861,4869 ----
  	    mark_reg_pointer (parmreg,
  			      TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm))));
  
+ 	  /* If something wants our address, try to use ADDRESSOF.  */
+ 	  if (TREE_ADDRESSABLE (parm))
+ 	    put_var_into_stack (parm);
  	}
        else
  	{
*** stmt.c.~1~	Sat Nov 11 23:29:59 2000
--- stmt.c	Sat Nov 11 23:30:07 2000
*************** expand_decl (decl)
*** 3837,3843 ****
  	   && !(flag_float_store
  		&& TREE_CODE (type) == REAL_TYPE)
  	   && ! TREE_THIS_VOLATILE (decl)
- 	   && ! TREE_ADDRESSABLE (decl)
  	   && (DECL_REGISTER (decl) || optimize)
  	   /* if -fcheck-memory-usage, check all variables.  */
  	   && ! current_function_check_memory_usage)
--- 3837,3842 ----
*************** expand_decl (decl)
*** 3855,3860 ****
--- 3854,3863 ----
  			  TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
  
        maybe_set_unchanging (DECL_RTL (decl), decl);
+ 
+       /* If something wants our address, try to use ADDRESSOF.  */
+       if (TREE_ADDRESSABLE (decl))
+ 	put_var_into_stack (decl);
      }
  
    else if (TREE_CODE (DECL_SIZE_UNIT (decl)) == INTEGER_CST
*** cp/typeck.c.~1~	Sat Nov 11 23:30:00 2000
--- cp/typeck.c	Sat Nov 11 23:30:10 2000
*************** mark_addressable (exp)
*** 4904,4910 ****
  	    if (! flag_this_is_variable)
  	      error ("cannot take the address of `this', which is an ravlue expression");
  	    TREE_ADDRESSABLE (x) = 1; /* so compiler doesn't die later */
- 	    put_var_into_stack (x);
  	    return 1;
  	  }
        case VAR_DECL:
--- 4904,4909 ----

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