This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] Fix stack usage increase for renaming of indexed component
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 18 Nov 2015 19:20:17 +0100
- Subject: [Ada] Fix stack usage increase for renaming of indexed component
- Authentication-results: sourceware.org; auth=none
This fixes an oversight in the new fold_constant_decl_in_expr function, which
causes the code generated by the compiler for the renaming of an indexed
component whose prefix is a constant object and whose index is not to use
significantly more stack than needed.
Tested on x86_64-suse-linux, applied on the mainline and 5.x branch.
2015-11-18 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (fold_constant_decl_in_expr) <ARRAY_REF>: If
the index is not itself constant then bail out.
--
Eric Botcazou
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c (revision 230542)
+++ gcc-interface/trans.c (working copy)
@@ -975,6 +975,9 @@ fold_constant_decl_in_expr (tree exp)
case ARRAY_REF:
case ARRAY_RANGE_REF:
+ /* If the index is not itself constant, then nothing can be folded. */
+ if (!TREE_CONSTANT (TREE_OPERAND (exp, 1)))
+ return exp;
op0 = fold_constant_decl_in_expr (TREE_OPERAND (exp, 0));
if (op0 == TREE_OPERAND (exp, 0))
return exp;