From 9ff0637e4475a9a436506de9d49a6c04b86b2364 Mon Sep 17 00:00:00 2001 From: uweigand Date: Mon, 24 May 2004 16:37:17 +0000 Subject: PR tree-optimization/14197 * builtins.c: Include "tree-gimple.h" (readonly_data_expr): Use get_base_address. Make sure to call decl_readonly_section only on trees it can handle. * tree-gimple.c (get_base_address): Accept STRING_CST and CONSTRUCTOR expressions. * Makefile.in: Update dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@82209 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/builtins.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'gcc/builtins.c') diff --git a/gcc/builtins.c b/gcc/builtins.c index 2457d661421..d56136a8804 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -27,6 +27,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "real.h" #include "rtl.h" #include "tree.h" +#include "tree-gimple.h" #include "flags.h" #include "regs.h" #include "hard-reg-set.h" @@ -7925,8 +7926,20 @@ readonly_data_expr (tree exp) { STRIP_NOPS (exp); - if (TREE_CODE (exp) == ADDR_EXPR) - return decl_readonly_section (TREE_OPERAND (exp, 0), 0); + if (TREE_CODE (exp) != ADDR_EXPR) + return false; + + exp = get_base_address (TREE_OPERAND (exp, 0)); + if (!exp) + return false; + + /* Make sure we call decl_readonly_section only for trees it + can handle (since it returns true for everything it doesn't + understand). */ + if (TREE_CODE (exp) == STRING_CST + || TREE_CODE (exp) == CONSTRUCTOR + || (TREE_CODE (exp) == VAR_DECL && TREE_STATIC (exp))) + return decl_readonly_section (exp, 0); else return false; } -- cgit v1.2.1