This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFC PATCH 1/9] LRA: Take account implicit usage of pseudo reg in mem arg
- From: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Cc: Oleg Endo <oleg dot endo at t-online dot de>
- Date: Thu, 18 Dec 2014 09:57:37 +0900 (JST)
- Subject: [RFC PATCH 1/9] LRA: Take account implicit usage of pseudo reg in mem arg
- Authentication-results: sourceware.org; auth=none
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);
}