t-aarch64-linux (MULTILIB_OSDIRNAMES): Handle multi-arch for ilp32.
[gcc.git] / gcc / var-tracking.c
index 2f68298ac78d2fc2b05cd7e18ea8979de9f21ddf..77281fb45ee228e8cb802bcf61aff989c9b2c580 100644 (file)
@@ -395,8 +395,9 @@ struct variable
 static inline HOST_WIDE_INT
 int_mem_offset (const_rtx mem)
 {
-  if (MEM_OFFSET_KNOWN_P (mem))
-    return MEM_OFFSET (mem);
+  HOST_WIDE_INT offset;
+  if (MEM_OFFSET_KNOWN_P (mem) && MEM_OFFSET (mem).is_constant (&offset))
+    return offset;
   return 0;
 }
 
@@ -3521,6 +3522,12 @@ loc_cmp (rtx x, rtx y)
        else
          return 1;
 
+      case 'p':
+       r = compare_sizes_for_sort (SUBREG_BYTE (x), SUBREG_BYTE (y));
+       if (r != 0)
+         return r;
+       break;
+
       case 'V':
       case 'E':
        /* Compare the vector length first.  */
@@ -5201,20 +5208,20 @@ track_expr_p (tree expr, bool need_rtl)
              || (TREE_CODE (realdecl) == MEM_REF
                  && TREE_CODE (TREE_OPERAND (realdecl, 0)) == ADDR_EXPR))
            {
-             HOST_WIDE_INT bitsize, bitpos, maxsize;
+             HOST_WIDE_INT bitsize, bitpos;
              bool reverse;
              tree innerdecl
-               = get_ref_base_and_extent (realdecl, &bitpos, &bitsize,
-                                          &maxsize, &reverse);
-             if (!DECL_P (innerdecl)
+               = get_ref_base_and_extent_hwi (realdecl, &bitpos,
+                                              &bitsize, &reverse);
+             if (!innerdecl
+                 || !DECL_P (innerdecl)
                  || DECL_IGNORED_P (innerdecl)
                  /* Do not track declarations for parts of tracked record
                     parameters since we want to track them as a whole.  */
                  || tracked_record_parameter_p (innerdecl)
                  || TREE_STATIC (innerdecl)
-                 || bitsize <= 0
-                 || bitpos + bitsize > 256
-                 || bitsize != maxsize)
+                 || bitsize == 0
+                 || bitpos + bitsize > 256)
                return 0;
              else
                realdecl = expr;
@@ -5256,7 +5263,7 @@ track_expr_p (tree expr, bool need_rtl)
          && !tracked_record_parameter_p (realdecl))
        return 0;
       if (MEM_SIZE_KNOWN_P (decl_rtl)
-         && MEM_SIZE (decl_rtl) > MAX_VAR_PARTS)
+         && maybe_gt (MEM_SIZE (decl_rtl), MAX_VAR_PARTS))
        return 0;
     }
 
@@ -5368,7 +5375,7 @@ track_loc_p (rtx loc, tree expr, poly_int64 offset, bool store_reg_p,
 static rtx
 var_lowpart (machine_mode mode, rtx loc)
 {
-  unsigned int offset, reg_offset, regno;
+  unsigned int regno;
 
   if (GET_MODE (loc) == mode)
     return loc;
@@ -5376,12 +5383,12 @@ var_lowpart (machine_mode mode, rtx loc)
   if (!REG_P (loc) && !MEM_P (loc))
     return NULL;
 
-  offset = byte_lowpart_offset (mode, GET_MODE (loc));
+  poly_uint64 offset = byte_lowpart_offset (mode, GET_MODE (loc));
 
   if (MEM_P (loc))
     return adjust_address_nv (loc, mode, offset);
 
-  reg_offset = subreg_lowpart_offset (mode, GET_MODE (loc));
+  poly_uint64 reg_offset = subreg_lowpart_offset (mode, GET_MODE (loc));
   regno = REGNO (loc) + subreg_regno_offset (REGNO (loc), GET_MODE (loc),
                                             reg_offset, mode);
   return gen_rtx_REG_offset (loc, mode, regno, offset);
@@ -9504,24 +9511,6 @@ emit_notes_in_bb (basic_block bb, dataflow_set *set)
     }
 }
 
-/* Return BB's head, unless BB is the block that succeeds ENTRY_BLOCK,
-   in which case it searches back from BB's head for the very first
-   insn.  Use [get_first_insn (bb), BB_HEAD (bb->next_bb)[ as a range
-   to iterate over all insns of a function while iterating over its
-   BBs.  */
-
-static rtx_insn *
-get_first_insn (basic_block bb)
-{
-  rtx_insn *insn = BB_HEAD (bb);
-
-  if (bb->prev_bb == ENTRY_BLOCK_PTR_FOR_FN (cfun))
-    while (rtx_insn *prev = PREV_INSN (insn))
-      insn = prev;
-
-  return insn;
-}
-
 /* Emit notes for the whole function.  */
 
 static void
@@ -9550,8 +9539,7 @@ vt_emit_notes (void)
     {
       /* Emit the notes for changes of variable locations between two
         subsequent basic blocks.  */
-      emit_notes_for_differences (get_first_insn (bb),
-                                 &cur, &VTI (bb)->in);
+      emit_notes_for_differences (BB_HEAD (bb), &cur, &VTI (bb)->in);
 
       if (MAY_HAVE_DEBUG_BIND_INSNS)
        local_get_addr_cache = new hash_map<rtx, rtx>;
@@ -9959,7 +9947,7 @@ vt_init_cfa_base (void)
 /* Reemit INSN, a MARKER_DEBUG_INSN, as a note.  */
 
 static rtx_insn *
-reemit_marker_as_note (rtx_insn *insn, basic_block *bb)
+reemit_marker_as_note (rtx_insn *insn)
 {
   gcc_checking_assert (DEBUG_MARKER_INSN_P (insn));
 
@@ -9974,8 +9962,6 @@ reemit_marker_as_note (rtx_insn *insn, basic_block *bb)
          {
            note = emit_note_before (kind, insn);
            NOTE_MARKER_LOCATION (note) = INSN_LOCATION (insn);
-           if (bb)
-             BLOCK_FOR_INSN (note) = *bb;
          }
        delete_insn (insn);
        return note;
@@ -10183,39 +10169,11 @@ vt_initialize (void)
          HOST_WIDE_INT offset = VTI (bb)->out.stack_adjust;
          VTI (bb)->out.stack_adjust = VTI (bb)->in.stack_adjust;
 
-         /* If we are walking the first basic block, walk any HEADER
-            insns that might be before it too.  Unfortunately,
-            BB_HEADER and BB_FOOTER are not set while we run this
-            pass.  */
          rtx_insn *next;
-         bool outside_bb = true;
-         for (insn = get_first_insn (bb); insn != BB_HEAD (bb->next_bb);
-              insn = next)
+         FOR_BB_INSNS_SAFE (bb, insn, next)
            {
-             if (insn == BB_HEAD (bb))
-               outside_bb = false;
-             else if (insn == NEXT_INSN (BB_END (bb)))
-               outside_bb = true;
-             next = NEXT_INSN (insn);
              if (INSN_P (insn))
                {
-                 if (outside_bb)
-                   {
-                     /* Ignore non-debug insns outside of basic blocks.  */
-                     if (!DEBUG_INSN_P (insn))
-                       continue;
-                     /* Debug binds shouldn't appear outside of bbs.  */
-                     gcc_assert (!DEBUG_BIND_INSN_P (insn));
-                   }
-                 basic_block save_bb = BLOCK_FOR_INSN (insn);
-                 if (!BLOCK_FOR_INSN (insn))
-                   {
-                     gcc_assert (outside_bb);
-                     BLOCK_FOR_INSN (insn) = bb;
-                   }
-                 else
-                   gcc_assert (BLOCK_FOR_INSN (insn) == bb);
-
                  if (!frame_pointer_needed)
                    {
                      insn_stack_adjust_offset_pre_post (insn, &pre, &post);
@@ -10237,7 +10195,7 @@ vt_initialize (void)
                  adjust_insn (bb, insn);
                  if (DEBUG_MARKER_INSN_P (insn))
                    {
-                     insn = reemit_marker_as_note (insn, &save_bb);
+                     reemit_marker_as_note (insn);
                      continue;
                    }
 
@@ -10289,7 +10247,6 @@ vt_initialize (void)
                            }
                        }
                    }
-                 BLOCK_FOR_INSN (insn) = save_bb;
                }
            }
          gcc_assert (offset == VTI (bb)->out.stack_adjust);
@@ -10331,15 +10288,12 @@ delete_vta_debug_insns (void)
 
   FOR_EACH_BB_FN (bb, cfun)
     {
-      for (insn = get_first_insn (bb);
-          insn != BB_HEAD (bb->next_bb)
-            ? next = NEXT_INSN (insn), true : false;
-          insn = next)
+      FOR_BB_INSNS_SAFE (bb, insn, next)
        if (DEBUG_INSN_P (insn))
          {
            if (DEBUG_MARKER_INSN_P (insn))
              {
-               insn = reemit_marker_as_note (insn, NULL);
+               reemit_marker_as_note (insn);
                continue;
              }