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]

[4.5/m32c] libstdc++ build crashes emitting debug_info


This is the same old pointer+int issue, but apparently the
debug-emitting code isn't as careful as the regular code.  This patch
checks for the case where we're emitting debug info for a
POINTER_PLUS_EXPR with mis-matched modes, and corrects the expression.
Without this patch, m32c-elf libstdc++ cannot be built with -g.
Tested with m32c-elf, which AFAIK is the only target with pointers
that are not the same size as any integer type.

	* cfgexpand.c (expand_debug_expr): Check for mismatched modes
	in POINTER_PLUS_EXPR and fix them.

Index: cfgexpand.c
===================================================================
--- cfgexpand.c	(revision 158175)
+++ cfgexpand.c	(working copy)
@@ -2615,12 +2615,27 @@ expand_debug_expr (tree exp)
       if (unsignedp)
 	return gen_rtx_UNSIGNED_FIX (mode, op0);
       else
 	return gen_rtx_FIX (mode, op0);
 
     case POINTER_PLUS_EXPR:
+      /* For the rare target where pointers are not the same size as
+	 size_t, we need to check for mis-matched modes and correct
+	 the addend.  */
+      if (op0 && op1
+	  && GET_MODE (op0) != VOIDmode && GET_MODE (op1) != VOIDmode
+	  && GET_MODE (op0) != GET_MODE (op1))
+	{
+	  if (GET_MODE_BITSIZE (GET_MODE (op0)) < GET_MODE_BITSIZE (GET_MODE (op1)))
+	    op1 = gen_rtx_TRUNCATE (GET_MODE (op0), op1);
+	  else if (TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1))))
+	    op1 = gen_rtx_ZERO_EXTEND (GET_MODE (op0), op1);
+	  else
+	    op1 = gen_rtx_SIGN_EXTEND (GET_MODE (op0), op1);
+	}
+      /* Fall through.  */
     case PLUS_EXPR:
       return gen_rtx_PLUS (mode, op0, op1);
 
     case MINUS_EXPR:
       return gen_rtx_MINUS (mode, op0, op1);
 


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