This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Fix stack usage increase for renaming of indexed component


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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]