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]

[PATCH] Fix Pmode != ptr_mode and AS handling in VTA (PR debug/47283)


Hi!

The g++.dg/debug/pr47283.C testcase ICEs on ia64-hp-hpux11.23
because expand_debug_expr didn't handle Pmode != ptr_mode right.
This patch should fix that, Steve Ellcey tested it on that target
and I've bootstrapped/regtested it on x86_64-linux and i686-linux, ok
for trunk?

2011-02-17  Jakub Jelinek  <jakub@redhat.com>

	PR debug/47283
	* cfgexpand.c (convert_debug_memory_address): Add AS parameter.
	Use target address_mode and pointer_mode hooks instead of hardcoded
	Pmode and ptr_mode.  Handle some simple cases of extending if
	POINTERS_EXTEND_UNSIGNED < 0.
	(expand_debug_expr) <case MEM_REF, INDIRECT_REF, TARGET_MEM_REF>:
	Call convert_debug_memory_address.
	(expand_debug_expr) <case ADDR_EXPR>: Pass as to
	convert_debug_memory_address.

--- gcc/cfgexpand.c.jj	2011-02-02 16:30:56.000000000 +0100
+++ gcc/cfgexpand.c	2011-02-16 09:46:39.000000000 +0100
@@ -2321,15 +2321,21 @@ round_udiv_adjust (enum machine_mode mod
    any rtl.  */
 
 static rtx
-convert_debug_memory_address (enum machine_mode mode, rtx x)
+convert_debug_memory_address (enum machine_mode mode, rtx x,
+			      addr_space_t as)
 {
   enum machine_mode xmode = GET_MODE (x);
 
 #ifndef POINTERS_EXTEND_UNSIGNED
-  gcc_assert (mode == Pmode);
+  gcc_assert (mode == Pmode
+	      || mode == targetm.addr_space.address_mode (as));
   gcc_assert (xmode == mode || xmode == VOIDmode);
 #else
-  gcc_assert (mode == Pmode || mode == ptr_mode);
+  rtx temp;
+  enum machine_mode address_mode = targetm.addr_space.address_mode (as);
+  enum machine_mode pointer_mode = targetm.addr_space.pointer_mode (as);
+
+  gcc_assert (mode == address_mode || mode == pointer_mode);
 
   if (GET_MODE (x) == mode || GET_MODE (x) == VOIDmode)
     return x;
@@ -2343,7 +2349,47 @@ convert_debug_memory_address (enum machi
   else if (!POINTERS_EXTEND_UNSIGNED)
     x = gen_rtx_SIGN_EXTEND (mode, x);
   else
-    gcc_unreachable ();
+    {
+      switch (GET_CODE (x))
+	{
+	case SUBREG:
+	  if ((SUBREG_PROMOTED_VAR_P (x)
+	       || (REG_P (SUBREG_REG (x)) && REG_POINTER (SUBREG_REG (x)))
+	       || (GET_CODE (SUBREG_REG (x)) == PLUS
+		   && REG_P (XEXP (SUBREG_REG (x), 0))
+		   && REG_POINTER (XEXP (SUBREG_REG (x), 0))
+		   && CONST_INT_P (XEXP (SUBREG_REG (x), 1))))
+	      && GET_MODE (SUBREG_REG (x)) == mode)
+	    return SUBREG_REG (x);
+	  break;
+	case LABEL_REF:
+	  temp = gen_rtx_LABEL_REF (mode, XEXP (x, 0));
+	  LABEL_REF_NONLOCAL_P (temp) = LABEL_REF_NONLOCAL_P (x);
+	  return temp;
+	case SYMBOL_REF:
+	  temp = shallow_copy_rtx (x);
+	  PUT_MODE (temp, mode);
+	  return temp;
+	case CONST:
+	  temp = convert_debug_memory_address (mode, XEXP (x, 0), as);
+	  if (temp)
+	    temp = gen_rtx_CONST (mode, temp);
+	  return temp;
+	case PLUS:
+	case MINUS:
+	  if (CONST_INT_P (XEXP (x, 1)))
+	    {
+	      temp = convert_debug_memory_address (mode, XEXP (x, 0), as);
+	      if (temp)
+		return gen_rtx_fmt_ee (GET_CODE (x), mode, temp, XEXP (x, 1));
+	    }
+	  break;
+	default:
+	  break;
+	}
+      /* Don't know how to express ptr_extend as operation in debug info.  */
+      return NULL;
+    }
 #endif /* POINTERS_EXTEND_UNSIGNED */
 
   return x;
@@ -2587,8 +2633,12 @@ expand_debug_expr (tree exp)
       else
 	as = ADDR_SPACE_GENERIC;
 
-      op0 = gen_rtx_MEM (mode, op0);
+      op0 = convert_debug_memory_address (targetm.addr_space.address_mode (as),
+					  op0, as);
+      if (op0 == NULL_RTX)
+	return NULL;
 
+      op0 = gen_rtx_MEM (mode, op0);
       set_mem_attributes (op0, exp, 0);
       set_mem_addr_space (op0, as);
 
@@ -2604,7 +2654,15 @@ expand_debug_expr (tree exp)
       if (!op0)
 	return NULL;
 
-      as = TYPE_ADDR_SPACE (TREE_TYPE (exp));
+      if (POINTER_TYPE_P (TREE_TYPE (exp)))
+	as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)));
+      else
+	as = ADDR_SPACE_GENERIC;
+
+      op0 = convert_debug_memory_address (targetm.addr_space.address_mode (as),
+					  op0, as);
+      if (op0 == NULL_RTX)
+	return NULL;
 
       op0 = gen_rtx_MEM (mode, op0);
 
@@ -3068,7 +3126,8 @@ expand_debug_expr (tree exp)
 	  return NULL;
 	}
 
-      op0 = convert_debug_memory_address (mode, XEXP (op0, 0));
+      as = TYPE_ADDR_SPACE (TREE_TYPE (exp));
+      op0 = convert_debug_memory_address (mode, XEXP (op0, 0), as);
 
       return op0;
 

	Jakub


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