https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84252

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rsandifo at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That patch changed behavior rather than just change representation from hwis to
poly_int*.

--- gcc/var-tracking.c.jj       2018-01-04 00:43:15.007702432 +0100
+++ gcc/var-tracking.c  2018-02-07 11:13:59.388135311 +0100
@@ -1853,8 +1853,7 @@ static bool
 track_offset_p (poly_int64 offset, HOST_WIDE_INT *offset_out)
 {
   HOST_WIDE_INT const_offset;
-  if (!offset.is_constant (&const_offset)
-      || !IN_RANGE (const_offset, 0, MAX_VAR_PARTS - 1))
+  if (!offset.is_constant (&const_offset))
     return false;
   *offset_out = const_offset;
   return true;
@@ -5355,7 +5354,8 @@ track_loc_p (rtx loc, tree expr, poly_in
     }

   HOST_WIDE_INT const_offset;
-  if (!track_offset_p (offset, &const_offset))
+  if (!track_offset_p (offset, &const_offset)
+      || !IN_RANGE (const_offset, 0, MAX_VAR_PARTS - 1))
     return false;

   if (mode_out)

would restore previous behavior.

The primary point of MAX_VAR_PARTS is to make sure that no value is tracked in
more than 16 parts, which in many cases is enforced just by giving up if we
need more than 16 bytes of memory or offsets above that, but other parts of the
code just care that not more than 16 unique offsets are tracked for the var.

The patch added:
          /* vt_get_decl_and_offset has already checked that the offset
             is a valid variable part.  */
comment which just isn't correct, because vt_get_decl_and_offset could have
failed and we'd still get here.

So, another possible fix is to:
--- gcc/var-tracking.c.jj       2018-01-04 00:43:15.007702432 +0100
+++ gcc/var-tracking.c  2018-02-07 12:47:09.735980882 +0100
@@ -9653,6 +9653,7 @@ vt_add_function_parameter (tree parm)
   poly_int64 offset;
   dataflow_set *out;
   decl_or_value dv;
+  bool incoming_ok = true;

   if (TREE_CODE (parm) != PARM_DECL)
     return;
@@ -9743,6 +9744,7 @@ vt_add_function_parameter (tree parm)

   if (!vt_get_decl_and_offset (incoming, &decl, &offset))
     {
+      incoming_ok = false;
       if (MEM_P (incoming))
        {
          /* This means argument is passed by invisible reference.  */
@@ -9861,6 +9863,10 @@ vt_add_function_parameter (tree parm)
     {
       int i;

+      /* The following code relies on vt_get_decl_and_offset returning true
for
+        incoming, which might not be always the case.  */
+      if (!incoming_ok)
+       return;
       for (i = 0; i < XVECLEN (incoming, 0); i++)
        {
          rtx reg = XEXP (XVECEXP (incoming, 0, i), 0);

Reply via email to