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]

ivops vs random rtl symbol creation


I ran into a problem testing the  new x86_64-mingw platform,
in that the backend has some sanity checks to verify that we
can either load the symbol via rip-relative addressing, or
that the symbol is marked for DLLIMPORT.

The ivopts pass was creating dummy SYMBOL_REFs and passing 
them through, which violated this assumption.

Here I make an effort to invoke encode_section_info when I
can, or failing that at least mark the SYMBOL_REF as local.
It doesn't necessarily test the same thing as we did before,
but it's as good as we can get, and at least it doesn't cause
this backend to ICE.


r~


+	* tree-ssa-loop-ivopts.c: Include target.h.
+	(produce_memory_decl_rtl): Pass the rtx through encode_section_info.
+	(get_address_cost): Force SYMBOL_FLAG_LOCAL set.
+	(force_expr_to_var_cost): Use produce_memory_decl_rtl.
+	* Makefile.in (tree-ssa-loop-ivopts.o): Depend on TARGET_H.

--- gcc/Makefile.in	(revision 123380)
+++ gcc/Makefile.in	(local)
@@ -2136,7 +2136,7 @@ tree-ssa-loop-ivopts.o : tree-ssa-loop-i
    output.h $(DIAGNOSTIC_H) $(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) \
    tree-pass.h $(GGC_H) $(RECOG_H) insn-config.h $(HASHTAB_H) $(SCEV_H) \
    $(CFGLOOP_H) $(PARAMS_H) langhooks.h $(BASIC_BLOCK_H) hard-reg-set.h \
-   tree-chrec.h $(VARRAY_H) tree-affine.h pointer-set.h
+   tree-chrec.h $(VARRAY_H) tree-affine.h pointer-set.h $(TARGET_H)
 tree-affine.o : tree-affine.c tree-affine.h $(CONFIG_H) \
    $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) \
    output.h $(DIAGNOSTIC_H) $(TM_H) coretypes.h $(TREE_DUMP_H)
--- gcc/tree-ssa-loop-ivopts.c	(revision 123380)
+++ gcc/tree-ssa-loop-ivopts.c	(local)
@@ -91,6 +91,7 @@ Software Foundation, 51 Franklin Street,
 #include "params.h"
 #include "langhooks.h"
 #include "tree-affine.h"
+#include "target.h"
 
 /* The infinite cost.  */
 #define INFTY 10000000
@@ -2380,11 +2381,17 @@ produce_memory_decl_rtl (tree obj, int *
     {
       const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (obj));
       x = gen_rtx_SYMBOL_REF (Pmode, name);
+      SET_SYMBOL_REF_DECL (x, obj);
+      x = gen_rtx_MEM (DECL_MODE (obj), x);
+      targetm.encode_section_info (obj, x, true);
     }
   else
-    x = gen_raw_REG (Pmode, (*regno)++);
+    {
+      x = gen_raw_REG (Pmode, (*regno)++);
+      x = gen_rtx_MEM (DECL_MODE (obj), x);
+    }
 
-  return gen_rtx_MEM (DECL_MODE (obj), x);
+  return x;
 }
 
 /* Prepares decl_rtl for variables referred in *EXPR_P.  Callback for
@@ -2943,6 +2950,12 @@ get_address_cost (bool symbol_present, b
 	  if (sym_p)
 	    {
 	      base = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (""));
+	      /* ??? We can run into trouble with some backends by presenting
+		 it with symbols which havn't been properly passed through
+		 targetm.encode_section_info.  By setting the local bit, we
+		 enhance the probability of things working.  */
+	      SYMBOL_REF_FLAGS (base) = SYMBOL_FLAG_LOCAL;
+
 	      if (off_p)
 		base = gen_rtx_fmt_e (CONST, Pmode,
 				      gen_rtx_fmt_ee (PLUS, Pmode,
@@ -3070,17 +3083,18 @@ force_expr_to_var_cost (tree expr)
 
   if (!costs_initialized)
     {
-      tree var = create_tmp_var_raw (integer_type_node, "test_var");
-      rtx x = gen_rtx_MEM (DECL_MODE (var),
-			   gen_rtx_SYMBOL_REF (Pmode, "test_var"));
-      tree addr;
       tree type = build_pointer_type (integer_type_node);
+      tree var, addr;
+      rtx x;
+
+      var = create_tmp_var_raw (integer_type_node, "test_var");
+      TREE_STATIC (var) = 1;
+      x = produce_memory_decl_rtl (var, NULL);
+      SET_DECL_RTL (var, x);
 
       integer_cost = computation_cost (build_int_cst (integer_type_node,
 						      2000));
 
-      SET_DECL_RTL (var, x);
-      TREE_STATIC (var) = 1;
       addr = build1 (ADDR_EXPR, type, var);
       symbol_cost = computation_cost (addr) + 1;
 


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