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]

[vta, vta4.4] accept VOIDmode LABEL_REFs in debug insns


Jakub told me some ports (s390x IIRC) created some labels with VOIDmode
rather than Pmode or ptrmode, and this caused the assertion that checks
that RTL got the expected mode to fail.

Rather than just accepting VOIDmode LABEL_REFs, which might prevent us
from recovering the correct mode, I've arranged for such modeless
LABEL_REFs to be wrapped by a CONST with the expected mode.

I'm installing the first patch below in the vta branch, and the second
in vta4.4.  The only difference is the use of CONST_INT_P rather than
GET_MODE/CONST_INT.

for  gcc/ChangeLog.vta
from  Alexandre Oliva  <aoliva@redhat.com>

	* cfgexpand.c (wrap_constant): Wrap VOIDmode LABEL_REFs.
	(unwrap_constant): Unwrap them.
	(expand_debug_locations): Accept them.
	
Index: gcc/cfgexpand.c
===================================================================
--- gcc/cfgexpand.c.orig	2009-08-04 06:10:25.000000000 -0300
+++ gcc/cfgexpand.c	2009-08-04 06:45:58.000000000 -0300
@@ -2230,28 +2230,40 @@ round_udiv_adjust (enum machine_mode mod
 rtx
 wrap_constant (enum machine_mode mode, rtx x)
 {
-  if (!CONST_INT_P (x) && GET_CODE (x) != CONST_FIXED
-      && (GET_CODE (x) != CONST_DOUBLE || GET_MODE (x) != VOIDmode))
+  if (GET_MODE (x) != VOIDmode)
     return x;
-  gcc_assert (mode != VOIDmode);
-  return gen_rtx_CONST (mode, x);
+
+  if (CONST_INT_P (x)
+      || GET_CODE (x) == CONST_FIXED
+      || GET_CODE (x) == CONST_DOUBLE
+      || GET_CODE (x) == LABEL_REF)
+    {
+      gcc_assert (mode != VOIDmode);
+
+      x = gen_rtx_CONST (mode, x);
+    }
+
+  return x;
 }
 
 /* Remove CONST wrapper added by wrap_constant().  */
 rtx
 unwrap_constant (rtx x)
 {
-  rtx orig = x;
+  rtx ret = x;
 
   if (GET_CODE (x) != CONST)
     return x;
 
   x = XEXP (x, 0);
-  if (!CONST_INT_P (x) && GET_CODE (x) != CONST_FIXED
-      && (GET_CODE (x) != CONST_DOUBLE || GET_MODE (x) != VOIDmode))
-    return orig;
 
-  return x;
+  if (CONST_INT_P (x)
+      || GET_CODE (x) == CONST_FIXED
+      || GET_CODE (x) == CONST_DOUBLE
+      || GET_CODE (x) == LABEL_REF)
+    ret = x;
+
+  return ret;
 }
 
 /* Return an RTX equivalent to the value of the tree expression
@@ -2903,9 +2915,10 @@ expand_debug_locations (void)
 
 	    gcc_assert (mode == GET_MODE (val)
 			|| (GET_MODE (val) == VOIDmode
-			    && (GET_CODE (val) == CONST_INT
+			    && (CONST_INT_P (val)
 				|| GET_CODE (val) == CONST_FIXED
-				|| GET_CODE (val) == CONST_DOUBLE)));
+				|| GET_CODE (val) == CONST_DOUBLE
+				|| GET_CODE (val) == LABEL_REF)));
 	  }
 
 	INSN_VAR_LOCATION_LOC (insn) = val;
for  gcc/ChangeLog.vta
from  Alexandre Oliva  <aoliva@redhat.com>

	* cfgexpand.c (wrap_constant): Wrap VOIDmode LABEL_REFs.
	(unwrap_constant): Unwrap them.
	(expand_debug_locations): Accept them.
	
Index: gcc/cfgexpand.c
===================================================================
--- gcc/cfgexpand.c.orig	2009-08-04 06:43:40.000000000 -0300
+++ gcc/cfgexpand.c	2009-08-04 06:44:40.000000000 -0300
@@ -1930,28 +1930,40 @@ round_udiv_adjust (enum machine_mode mod
 rtx
 wrap_constant (enum machine_mode mode, rtx x)
 {
-  if (GET_CODE (x) != CONST_INT && GET_CODE (x) != CONST_FIXED
-      && (GET_CODE (x) != CONST_DOUBLE || GET_MODE (x) != VOIDmode))
+  if (GET_MODE (x) != VOIDmode)
     return x;
-  gcc_assert (mode != VOIDmode);
-  return gen_rtx_CONST (mode, x);
+
+  if (GET_CODE (x) == CONST_INT
+      || GET_CODE (x) == CONST_FIXED
+      || GET_CODE (x) == CONST_DOUBLE
+      || GET_CODE (x) == LABEL_REF)
+    {
+      gcc_assert (mode != VOIDmode);
+
+      x = gen_rtx_CONST (mode, x);
+    }
+
+  return x;
 }
 
 /* Remove CONST wrapper added by wrap_constant().  */
 rtx
 unwrap_constant (rtx x)
 {
-  rtx orig = x;
+  rtx ret = x;
 
   if (GET_CODE (x) != CONST)
     return x;
 
   x = XEXP (x, 0);
-  if (GET_CODE (x) != CONST_INT && GET_CODE (x) != CONST_FIXED
-      && (GET_CODE (x) != CONST_DOUBLE || GET_MODE (x) != VOIDmode))
-    return orig;
 
-  return x;
+  if (GET_CODE (x) == CONST_INT
+      || GET_CODE (x) == CONST_FIXED
+      || GET_CODE (x) == CONST_DOUBLE
+      || GET_CODE (x) == LABEL_REF)
+    ret = x;
+
+  return ret;
 }
 
 /* Return an RTX equivalent to the value of the tree expression
@@ -2594,7 +2606,8 @@ expand_debug_locations (void)
 			|| (GET_MODE (val) == VOIDmode
 			    && (GET_CODE (val) == CONST_INT
 				|| GET_CODE (val) == CONST_FIXED
-				|| GET_CODE (val) == CONST_DOUBLE)));
+				|| GET_CODE (val) == CONST_DOUBLE
+				|| GET_CODE (val) == LABEL_REF)));
 	  }
 
 	INSN_VAR_LOCATION_LOC (insn) = val;
-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

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