aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-12-15 20:56:58 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-12-15 20:56:58 +0000
commit5a626f11f4069f2b9d8f16ca9d8c210a5458cd6c (patch)
tree18d9c146d9ba14245e6cb2304f543a4a820ae3f0
parent4d9af632c473c98fdca77cd26fa0113f93bdb9e6 (diff)
downloadgcc-5a626f11f4069f2b9d8f16ca9d8c210a5458cd6c.zip
gcc-5a626f11f4069f2b9d8f16ca9d8c210a5458cd6c.tar.gz
gcc-5a626f11f4069f2b9d8f16ca9d8c210a5458cd6c.tar.bz2
builtins.c (expand_builtin_mathfn): Make sure not to expand the argument more than once.
* builtins.c (expand_builtin_mathfn): Make sure not to expand the argument more than once. From-SVN: r30963
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/builtins.c9
2 files changed, 13 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5e8cfed..0462e45 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+1999-12-15 Mark Mitchell <mark@codesourcery.com>
+
+ * builtins.c (expand_builtin_mathfn): Make sure not to expand the
+ argument more than once.
+
1999-12-15 Jason Merrill <jason@casey.cygnus.com>
* stmt.c (expand_decl): Expand upper bound of a dynamic array.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index ffc84fd..f03a53f 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -1182,9 +1182,16 @@ expand_builtin_mathfn (exp, target, subtarget)
&& TREE_CODE (TREE_VALUE (arglist)) != PARM_DECL)
{
exp = copy_node (exp);
- arglist = copy_node (arglist);
TREE_OPERAND (exp, 1) = arglist;
+ /* Wrap the computation of the argument in a SAVE_EXPR. That
+ way, if we need to expand the argument again (as in the
+ flag_errno_math case below where we cannot directly set
+ errno), we will not perform side-effects more than once.
+ Note that here we're mutating the original EXP as well as the
+ copy; that's the right thing to do in case the original EXP
+ is expanded later. */
TREE_VALUE (arglist) = save_expr (TREE_VALUE (arglist));
+ arglist = copy_node (arglist);
}
op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);