This is the mail archive of the
mailing list for the GCC project.
[Ada] get rid of systematic SAVE_EXPR for checks
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 19 Jun 2009 20:20:12 +0200
- Subject: [Ada] get rid of systematic SAVE_EXPR for checks
Most of the SAVE_EXPRs that used to be built systematically in Gigi for checks
have been eliminated by Geert for GCC 4.4; the only one that we were forced to
/* ??? 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);
in emit_check because of the exponential explosion during unsharing. The
attached patch gets rid of it by protecting complex expressions instead.
Tested on i586-suse-linux and applied on the mainline.
2009-06-19 Eric Botcazou <firstname.lastname@example.org>
* gcc-interface/trans.c (emit_check): Do not wrap up the result
in a SAVE_EXPR.
(protect_multiple_eval): Always protect complex expressions.
--- gcc-interface/trans.c (revision 148518)
+++ gcc-interface/trans.c (working copy)
@@ -6610,10 +6610,7 @@ emit_check (tree gnu_cond, tree gnu_expr
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))))
/* If this is a conversion, protect what's inside the conversion.