RFC: PR rtl-optimization/47958: [x32] reload generates invalid address reference

H.J. Lu hongjiu.lu@intel.com
Wed Mar 2 17:29:00 GMT 2011


Hi,

When we force a symbol reference in the constant pool, it should be
in ptr_mode even if symbol is in Pmode.  This patch does it.  Does
it make any senses?

Thanks.


H.J.
---
diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 497866d..628841d 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,9 @@
+2011-03-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR rtl-optimization/47958
+	* varasm.c (force_const_mem): Force symbol reference in
+	ptr_mode.
+
 2011-03-01  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/47744
diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32
index c57f5ca..22345df 100644
--- a/gcc/testsuite/ChangeLog.x32
+++ b/gcc/testsuite/ChangeLog.x32
@@ -1,3 +1,8 @@
+2011-03-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR rtl-optimization/47958
+	* gcc.dg/torture/pr47958-1.c: New.
+
 2011-03-01  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/47744
diff --git a/gcc/testsuite/gcc.dg/torture/pr47958-1.c b/gcc/testsuite/gcc.dg/torture/pr47958-1.c
new file mode 100644
index 0000000..9fdf142
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr47958-1.c
@@ -0,0 +1,13 @@
+/* { dg-do assemble } */
+
+void (*foo[6][6]) (int);
+void bar (hdR)
+    int hdR;
+{ }
+void xxx ()
+{
+    unsigned int i, j;
+    for (i = 0; i < 6; ++i)
+	for (j = 0; j < 6; ++j)
+            foo [i][j] = bar;
+}
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 9887fe4..b4e29f6 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -3511,6 +3511,13 @@ force_const_mem (enum machine_mode mode, rtx x)
   if (targetm.cannot_force_const_mem (x))
     return NULL_RTX;
 
+  /* Symbol reference in the constant pool must be in ptr_mode.  */
+  if (Pmode != ptr_mode
+      && mode == Pmode
+      && GET_MODE (x) == Pmode
+      && GET_CODE (x) == SYMBOL_REF)
+    mode = ptr_mode;
+
   /* Record that this function has used a constant pool entry.  */
   crtl->uses_const_pool = 1;
 



More information about the Gcc-patches mailing list