From: Ulrich Weigand Date: Mon, 24 May 2004 16:37:17 +0000 (+0000) Subject: re PR tree-optimization/14197 (Wrong code for bcopy/memmove (string-asm-2.c)) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aef0afc4f41cab8148ee17a4ea7dddb6fca0342e;p=gcc.git re PR tree-optimization/14197 (Wrong code for bcopy/memmove (string-asm-2.c)) 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. From-SVN: r82209 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7d5ddfbc8fc..ced1a4d5499 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2004-05-24 Ulrich Weigand + + 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. + 2004-05-23 Paolo Bonzini Move libcpp to the toplevel. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index c39920d04da..641ce2f6068 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1766,8 +1766,8 @@ dojump.o : dojump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_ flags.h function.h $(EXPR_H) $(OPTABS_H) $(INSN_ATTR_H) insn-config.h \ langhooks.h $(GGC_H) gt-dojump.h builtins.o : builtins.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H)\ - flags.h $(TARGET_H) function.h $(REGS_H) $(EXPR_H) $(OPTABS_H) insn-config.h \ - $(RECOG_H) output.h typeclass.h hard-reg-set.h toplev.h hard-reg-set.h \ + $(TREE_GIMPLE_H) flags.h $(TARGET_H) function.h $(REGS_H) $(EXPR_H) $(OPTABS_H) \ + insn-config.h $(RECOG_H) output.h typeclass.h hard-reg-set.h toplev.h hard-reg-set.h \ except.h $(TM_P_H) $(PREDICT_H) libfuncs.h real.h langhooks.h calls.o : calls.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) flags.h \ $(EXPR_H) $(OPTABS_H) langhooks.h $(TARGET_H) \ 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; } diff --git a/gcc/tree-gimple.c b/gcc/tree-gimple.c index dbe2966e1e9..18bc2f8afa3 100644 --- a/gcc/tree-gimple.c +++ b/gcc/tree-gimple.c @@ -574,6 +574,8 @@ get_base_address (tree t) do { if (SSA_VAR_P (t) + || TREE_CODE (t) == STRING_CST + || TREE_CODE (t) == CONSTRUCTOR || TREE_CODE (t) == INDIRECT_REF) return t;