summaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-19 18:18:54 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-19 18:18:54 +0000
commitf1556d890022ee37b09cbce9b1d513188099ec57 (patch)
tree866ee4024661709e4c172685223da255f18a8114 /gcc/ada
parentc451bee6e149aafa1872d90dcc719f50d73c6cfb (diff)
downloadgcc-f1556d890022ee37b09cbce9b1d513188099ec57.tar.gz
* gcc-interface/trans.c (emit_check): Do not wrap up the result
in a SAVE_EXPR. (protect_multiple_eval): Always protect complex expressions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148723 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/gcc-interface/trans.c16
2 files changed, 16 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 194ac3706b4..b03304f1ce2 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2009-06-19 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/trans.c (emit_check): Do not wrap up the result
+ in a SAVE_EXPR.
+ (protect_multiple_eval): Always protect complex expressions.
+
2009-06-19 Emmanuel Briot <briot@adacore.com>
* prj-ext.adb, makeutl.adb, makeutl.ads (Executable_Prefix_Path): Now
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index b59af8cdb19..ed9337c3389 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -6610,10 +6610,7 @@ emit_check (tree gnu_cond, tree gnu_expr, int reason, Node_Id gnat_node)
we don't need to evaluate it just for the check. */
TREE_SIDE_EFFECTS (gnu_result) = TREE_SIDE_EFFECTS (gnu_expr);
- /* ??? Unfortunately, if we don't put a SAVE_EXPR around this whole thing,
- we will repeatedly do the test and, at compile time, we will repeatedly
- visit it during unsharing, which leads to an exponential explosion. */
- return save_expr (gnu_result);
+ return gnu_result;
}
/* Return an expression that converts GNU_EXPR to GNAT_TYPE, doing overflow
@@ -7229,8 +7226,15 @@ protect_multiple_eval (tree exp)
{
tree type = TREE_TYPE (exp);
- /* If this has no side effects, we don't need to do anything. */
- if (!TREE_SIDE_EFFECTS (exp))
+ /* If EXP has no side effects, we theoritically don't need to do anything.
+ However, we may be recursively passed more and more complex expressions
+ involving checks which will be reused multiple times and eventually be
+ unshared for gimplification; in order to avoid a complexity explosion
+ at that point, we protect any expressions more complex than a simple
+ arithmetic expression. */
+ if (!TREE_SIDE_EFFECTS (exp)
+ && (CONSTANT_CLASS_P (exp)
+ || !EXPRESSION_CLASS_P (skip_simple_arithmetic (exp))))
return exp;
/* If this is a conversion, protect what's inside the conversion.