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]

Re: [PATCH]: CALL_EXPR should set TREE_SIDE_EFFECTS


> Index: tree.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/tree.c,v
> retrieving revision 1.325
> diff -c -3 -p -r1.325 tree.c
> *** tree.c	20 Aug 2003 21:46:46 -0000	1.325
> --- tree.c	25 Aug 2003 11:29:53 -0000
> *************** build (enum tree_code code, tree tt, ...
> *** 2334,2339 ****
> --- 2334,2354 ----
>   	    TREE_READONLY (t) = 0;
>   	  if (!TREE_CONSTANT (arg0))
>   	    constant = 0;
> + 	  if (code == CALL_EXPR)
> + 	    {
> + 	      /* Calls have side-effects, except those to const or
> + 		 pure functions.  */
> + 	      if (TREE_CODE (arg0) != ADDR_EXPR)
> + 		TREE_SIDE_EFFECTS (t) = 1;
> + 	      else
> + 		{
> + 		  tree fn = TREE_OPERAND (arg0, 0);
> + 
> + 		  if (TREE_CODE (fn) != FUNCTION_DECL
> + 		      || (!DECL_IS_PURE (fn) && !TREE_READONLY (fn)))
> + 		    TREE_SIDE_EFFECTS (t) = 1;
> + 		}
> + 	    }

I hate to ask you to go around on this yet again, but how about building
the node and then using "get_callee_fndecl"?  (And then doing the tests
for const/pure?)

I think that would get one additional case at the moment; a call through
a const pointer-to-function whose initializer is known.  And, if
get_callee_fndecl gets smarter, this code would automatically do better
too.

Thoughts?

Certainly OK with that change.

Thanks,

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com


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