Fix PR debug/60655 part 2.
authorRamana Radhakrishnan <ramana.radhakrishnan@arm.com>
Thu, 10 Apr 2014 08:13:30 +0000 (08:13 +0000)
committerRamana Radhakrishnan <ramana@gcc.gnu.org>
Thu, 10 Apr 2014 08:13:30 +0000 (08:13 +0000)
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.

From-SVN: r209269

gcc/ChangeLog
gcc/config/arm/arm.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr60655-2.c [new file with mode: 0644]

index d55168e56916b99233cf5a3523a668a8d3efb57b..4e1ef1f3e47c7b8786f00ab0e6f7f52002ac90c6 100644 (file)
@@ -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 0240cc70e815cbfd8d0a8e7cb2a952b20943ce05..e5cf5036631dd27cbe8b5641a40c04c496314742 100644 (file)
@@ -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_attribute_table[] =
 #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;
 \f
 /* 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"
index f73ef9b481b61357a4c721b6a57825852e82b905..a2008d6dde07e38f9f0961a1be266c4fee582b9c 100644 (file)
@@ -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
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr60655-2.c b/gcc/testsuite/gcc.c-torture/compile/pr60655-2.c
new file mode 100644 (file)
index 0000000..f33db64
--- /dev/null
@@ -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));
+}