This patch is discussed in PR55212

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55212#c47
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55212#c48
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55212#c49

and is to avoid segfault in remove_pseudos.
In the problematic case in #c47, a call_insn has a note for an argument
via memory:
  (expr_list:DF (use (mem:DF (reg/f:SI 699) [0  S8 A32]))
and this usage of pseudo 699 was missed by LRA.  spill_hard_reg[699]
doesn't have correct value and causes a segfault in remove_pseudos.

--
        * lra.c (lra_update_insn_regno_info): Take account of arguments
        via memory which could be implicit usage of pseudo regs.

diff --git a/lra.c b/lra.c
index 6535063..99564c2 100644
--- a/lra.c
+++ b/lra.c
@@ -1633,6 +1633,20 @@ lra_update_insn_regno_info (rtx_insn *insn)
   if ((code = GET_CODE (PATTERN (insn))) == CLOBBER || code == USE)
     add_regs_to_insn_regno_info (data, XEXP (PATTERN (insn), 0), uid,
                                 code == USE ? OP_IN : OP_OUT, false);
+  if (CALL_P (insn))
+    {
+      rtx link;
+
+      /* Take account of arguments via memory which could be implicit
+        usage of pseudo regs.  */
+      for (link = CALL_INSN_FUNCTION_USAGE (insn);
+          link != NULL_RTX;
+          link = XEXP (link, 1))
+       if (GET_CODE (XEXP (link, 0)) == USE
+           && MEM_P (XEXP (XEXP (link, 0), 0)))
+         add_regs_to_insn_regno_info (data, XEXP (XEXP (link, 0), 0), uid,
+                                      OP_IN, false);
+    }
   if (NONDEBUG_INSN_P (insn))
     setup_insn_reg_info (data, freq);
 }

Reply via email to