diff mbox

[PR,debug/60655] Reject invalid constants in the backend.

Message ID 534652AF.7060106@arm.com
State New
Headers show

Commit Message

Ramana Radhakrishnan April 10, 2014, 8:13 a.m. UTC
Hi,

This fixes the tail of PR60655 where there were still issues without 
-fdata-sections despite the fix in const_ok_for_output_1. For now, given 
the pressure to get 4.9 out of the door, it's probably best to handle 
this in the backend and reject constants that cannot be handled by GAS. 
For stage1 next we need to tighten the kinds of constants that 
var-tracking / const_ok_for_output_1 can handle but this is something we 
need to do across targets rather than leaving targets to deal with this.

I've tested this with bootstraps on AArch32 v7-a vfpv3-d16 thumb2 which 
is the typical distro configuration - testing came back clean.

Applied to trunk.

regards
Ramana

2014-04-10  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

         PR debug/60655
         * config/arm/arm.c (TARGET_CONST_NOT_OK_FOR_DEBUG_P): Define
         (arm_const_not_ok_for_debug_p): Reject MINUS with SYM_REF's
         ameliorating the cases where it can be.

2014-04-10  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

         PR debug/60655
         * gcc.c-torture/compile/pr60655-2.c: Copy from pr60655-1.c without
         -fdata-sections.
diff mbox

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 209261)
+++ ChangeLog	(working copy)
@@ -1,3 +1,10 @@ 
+2014-04-10  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
+
+	PR debug/60655
+	* config/arm/arm.c (TARGET_CONST_NOT_OK_FOR_DEBUG_P): Define
+	(arm_const_not_ok_for_debug_p): Reject MINUS with SYM_REF's
+	ameliorating the cases where it can be.
+
 2014-04-09  David Edelsohn  <dje.gcc@gmail.com>
 
 	Revert
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog	(revision 209261)
+++ testsuite/ChangeLog	(working copy)
@@ -1,3 +1,9 @@ 
+2014-04-10  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
+
+	PR debug/60655
+	* gcc.c-torture/compile/pr60655-2.c: Copy from pr60655-1.c without
+	-fdata-sections.
+
 2014-04-09  Steve Ellcey  <sellcey@mips.com>
 
 	* gcc.dg/tree-ssa/ssa-ifcombine-13.c: Remove mips*-*-* from option
Index: testsuite/gcc.c-torture/compile/pr60655-2.c
===================================================================
--- testsuite/gcc.c-torture/compile/pr60655-2.c	(revision 0)
+++ testsuite/gcc.c-torture/compile/pr60655-2.c	(working copy)
@@ -0,0 +1,30 @@ 
+
+typedef unsigned char unit;
+typedef unit *unitptr;
+extern short global_precision;
+typedef __SIZE_TYPE__ size_t;
+extern void *memcpy (void *dest, const void *src, size_t n);
+
+short mp_compare(const unit* r1, const unit* r2)
+{
+  register short precision;
+  precision = global_precision;
+  (r1) = ((r1)+(precision)-1);
+  (r2) = ((r2)+(precision)-1);
+  do
+    { if (*r1 < *r2)
+	return(-1);
+      if (*((r1)--) > *((r2)--))
+	return(1);
+    } while (--precision);
+}
+
+static unit modulus[((1280+(2*8))/8)];
+static unit d_data[((1280+(2*8))/8)*2];
+
+int upton_modmult (unitptr prod, unitptr multiplicand, unitptr multiplier)
+{
+ unitptr d = d_data;
+ while (mp_compare(d,modulus) > 0)
+   memcpy((void*)(prod), (const void*)(d), (global_precision));
+}
Index: config/arm/arm.c
===================================================================
--- config/arm/arm.c	(revision 209261)
+++ config/arm/arm.c	(working copy)
@@ -72,6 +72,7 @@  struct four_ints
 };
 
 /* Forward function declarations.  */
+static bool arm_const_not_ok_for_debug_p (rtx);
 static bool arm_lra_p (void);
 static bool arm_needs_doubleword_align (enum machine_mode, const_tree);
 static int arm_compute_static_chain_stack_bytes (void);
@@ -674,6 +675,9 @@  static const struct attribute_spec arm_a
 #undef TARGET_CAN_USE_DOLOOP_P
 #define TARGET_CAN_USE_DOLOOP_P can_use_doloop_if_innermost
 
+#undef TARGET_CONST_NOT_OK_FOR_DEBUG_P
+#define TARGET_CONST_NOT_OK_FOR_DEBUG_P arm_const_not_ok_for_debug_p
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Obstack for minipool constant handling.  */
@@ -31116,4 +31120,46 @@  arm_asan_shadow_offset (void)
   return (unsigned HOST_WIDE_INT) 1 << 29;
 }
 
+
+/* This is a temporary fix for PR60655.  Ideally we need
+   to handle most of these cases in the generic part but
+   currently we reject minus (..) (sym_ref).  We try to 
+   ameliorate the case with minus (sym_ref1) (sym_ref2)
+   where they are in the same section.  */
+
+static bool
+arm_const_not_ok_for_debug_p (rtx p)
+{
+  tree decl_op0 = NULL;
+  tree decl_op1 = NULL;
+
+  if (GET_CODE (p) == MINUS)
+    {
+      if (GET_CODE (XEXP (p, 1)) == SYMBOL_REF)
+	{
+	  decl_op1 = SYMBOL_REF_DECL (XEXP (p, 1));
+	  if (decl_op1
+	      && GET_CODE (XEXP (p, 0)) == SYMBOL_REF
+	      && (decl_op0 = SYMBOL_REF_DECL (XEXP (p, 0))))
+	    {
+	      if ((TREE_CODE (decl_op1) == VAR_DECL
+		   || TREE_CODE (decl_op1) == CONST_DECL)
+		  && (TREE_CODE (decl_op0) == VAR_DECL
+		      || TREE_CODE (decl_op0) == CONST_DECL))
+		return (get_variable_section (decl_op1, false)
+			!= get_variable_section (decl_op0, false));
+
+	      if (TREE_CODE (decl_op1) == LABEL_DECL
+		  && TREE_CODE (decl_op0) == LABEL_DECL)
+		return (DECL_CONTEXT (decl_op1)
+			!= DECL_CONTEXT (decl_op0));
+	    }
+
+	  return true;
+	}
+    }
+
+  return false;
+}
+
 #include "gt-arm.h"