PR tree-optimization/14197
authoruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 May 2004 16:37:17 +0000 (16:37 +0000)
committeruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 May 2004 16:37:17 +0000 (16:37 +0000)
* 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/ChangeLog
gcc/Makefile.in
gcc/builtins.c
gcc/tree-gimple.c

index 7d5ddfb..ced1a4d 100644 (file)
@@ -1,3 +1,13 @@
+2004-05-24  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       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  <bonzini@gnu.org>
 
        Move libcpp to the toplevel.
index c39920d..641ce2f 100644 (file)
@@ -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) \
index 2457d66..d56136a 100644 (file)
@@ -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;
 }
index dbe2966..18bc2f8 100644 (file)
@@ -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;