This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch to projects.html: glibc's string function macros
- To: mark at codesourcery dot com, rth at cygnus dot com
- Subject: Re: Patch to projects.html: glibc's string function macros
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Tue, 31 Oct 2000 13:44:31 -0500 (EST)
- Cc: gcc-patches at gcc dot gnu dot org, jsm28 at cam dot ac dot uk
> From: Mark Mitchell <mark@codesourcery.com>
>
> >>>>> "Richard" == Richard Henderson <rth@cygnus.com> writes:
>
> Richard> Ok.
>
> Just one minor thought: since expand_expr already knows not to bother
> expanding things that don't have side-effects, I think we should just
> always call it in these kinds of places. That will keep the code
> simpler.
Okay, I followed your suggestion. Here's the revised bit that always
calls expand_expr.
Checked (in along with the testcase) after passing bootstrap/testsuite
on solaris2.7.
Index: builtins.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/builtins.c,v
retrieving revision 1.60
diff -u -p -r1.60 builtins.c
--- builtins.c 2000/10/06 14:59:56 1.60
+++ builtins.c 2000/10/31 18:21:33
@@ -2351,7 +2351,13 @@ expand_builtin_fputs (arglist, ignore)
switch (compare_tree_int (len, 1))
{
case -1: /* length is 0, delete the call entirely . */
- return const0_rtx;
+ {
+ /* Evaluate and ignore the argument in case it has
+ side-effects. */
+ expand_expr (TREE_VALUE (TREE_CHAIN (arglist)), const0_rtx,
+ VOIDmode, EXPAND_NORMAL);
+ return const0_rtx;
+ }
case 0: /* length is 1, call fputc. */
{
tree stripped_string = TREE_VALUE (arglist);