]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[LRA]: When assigning stack slots to pseudos previously assigned to fp consider other...
authorVladimir N. Makarov <vmakarov@redhat.com>
Thu, 17 Aug 2023 15:57:45 +0000 (11:57 -0400)
committerVladimir N. Makarov <vmakarov@redhat.com>
Thu, 17 Aug 2023 16:01:49 +0000 (12:01 -0400)
The previous LRA patch can assign slot of conflicting pseudos to
pseudos spilled after prohibiting fp->sp elimination.  This patch
fixes this problem.

gcc/ChangeLog:

* lra-spills.cc (assign_stack_slot_num_and_sort_pseudos): Moving
slots_num initialization from here ...
(lra_spill): ... to here before the 1st call of
assign_stack_slot_num_and_sort_pseudos.  Add the 2nd call after
fp->sp elimination.

gcc/lra-spills.cc

index 7e1d35b5e4e8289a376b1ef4822fc91942da132b..a663a1931e30b0462908bb83952618c92f2be8fb 100644 (file)
@@ -363,7 +363,6 @@ assign_stack_slot_num_and_sort_pseudos (int *pseudo_regnos, int n)
 {
   int i, j, regno;
 
-  slots_num = 0;
   /* Assign stack slot numbers to spilled pseudos, use smaller numbers
      for most frequently used pseudos. */
   for (i = 0; i < n; i++)
@@ -628,6 +627,7 @@ lra_spill (void)
   /* Sort regnos according their usage frequencies.  */
   qsort (pseudo_regnos, n, sizeof (int), regno_freq_compare);
   n = assign_spill_hard_regs (pseudo_regnos, n);
+  slots_num = 0;
   assign_stack_slot_num_and_sort_pseudos (pseudo_regnos, n);
   for (i = 0; i < n; i++)
     if (pseudo_slots[pseudo_regnos[i]].mem == NULL_RTX)
@@ -635,6 +635,7 @@ lra_spill (void)
   if ((n2 = lra_update_fp2sp_elimination (pseudo_regnos)) > 0)
     {
       /* Assign stack slots to spilled pseudos assigned to fp.  */
+      assign_stack_slot_num_and_sort_pseudos (pseudo_regnos, n2);
       for (i = 0; i < n2; i++)
        if (pseudo_slots[pseudo_regnos[i]].mem == NULL_RTX)
          assign_mem_slot (pseudo_regnos[i]);