Patch to expand_call

Jason Merrill jason@cygnus.com
Tue Jan 19 13:01:00 GMT 1999


We were doing an extra copy on targets that pass by invisible reference.

1999-01-19  Jason Merrill  <jason@yorick.cygnus.com>

	* calls.c (expand_call): Strip a TARGET_EXPR if we're passing by
	invisible reference.

Index: calls.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/calls.c,v
retrieving revision 1.40
diff -c -p -r1.40 calls.c
*** calls.c	1999/01/19 10:31:39	1.40
--- calls.c	1999/01/19 19:53:19
*************** expand_call (exp, target, ignore)
*** 1345,1350 ****
--- 1345,1366 ----
  #endif
  	      )
  	    {
+ 	      /* C++ uses a TARGET_EXPR to indicate that we want to make a
+ 	         new object from the argument.  If we are passing by
+ 	         invisible reference, the callee will do that for us, so we
+ 	         can strip off the TARGET_EXPR.  This is not always safe,
+ 	         but it is safe in the only case where this is a useful
+ 	         optimization; namely, when the argument is a plain object.
+ 	         In that case, the frontend is just asking the backend to
+ 	         make a bitwise copy of the argument. */
+ 		 
+ 	      if (TREE_CODE (args[i].tree_value) == TARGET_EXPR
+ 		  && (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND
+ 						  (args[i].tree_value, 1)))
+ 		      == 'd')
+ 		  && ! REG_P (DECL_RTL (TREE_OPERAND (args[i].tree_value, 1))))
+ 		args[i].tree_value = TREE_OPERAND (args[i].tree_value, 1);
+ 
  	      args[i].tree_value = build1 (ADDR_EXPR,
  					   build_pointer_type (type),
  					   args[i].tree_value);



More information about the Gcc-patches mailing list