This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix gcse leak
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Steven Bosscher <stevenb dot gcc at gmail dot com>,GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: David Malcolm <dmalcolm at redhat dot com>
- Date: Sun, 11 May 2014 17:24:23 +0200
- Subject: Re: Fix gcse leak
- Authentication-results: sourceware.org; auth=none
- References: <CABu31nP9RH5=WDY_8Q+aj_xzMFa2OTrWPxc_syiye2ZL4DuPiQ at mail dot gmail dot com>
On May 11, 2014 3:54:30 PM CEST, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
>Hello,
>
>This patch plugs a GGC leak in gcse.c, which will hold on to test insn
>to save memory. But this results in holding on to entire RTL function
>bodies, the function's CFG, and a lot more.
>
>Fix is simple: Clear the part of test_insn that causes this.
>
>Bootstrapped&tested on powerpc64-unknown-linux-gnu.
>OK for trunk?
OK.
Thanks,
Richard.
>Ciao!
>Steven
>
>
> * gcse.c (can_assign_to_reg_without_clobbers_p): Do not let pointers
> from test_insn into GGC space escape via SET_SRC.
>
>Index: gcse.c
>===================================================================
>--- gcse.c (revision 209530)
>+++ gcse.c (working copy)
>@@ -849,6 +849,7 @@ can_assign_to_reg_without_clobbers_p (rtx x)
> {
> int num_clobbers = 0;
> int icode;
>+ bool can_assign = false;
>
>/* If this is a valid operand, we are OK. If it's VOIDmode, we aren't.
> */
> if (general_operand (x, GET_MODE (x)))
>@@ -866,6 +867,7 @@ can_assign_to_reg_without_clobbers_p (rtx x)
> FIRST_PSEUDO_REGISTER * 2),
> const0_rtx));
> NEXT_INSN (test_insn) = PREV_INSN (test_insn) = 0;
>+ INSN_LOCATION (test_insn) = UNKNOWN_LOCATION;
> }
>
>/* Now make an insn like the one we would make when GCSE'ing and see if
>@@ -874,16 +876,19 @@ can_assign_to_reg_without_clobbers_p (rtx x)
> SET_SRC (PATTERN (test_insn)) = x;
>
> icode = recog (PATTERN (test_insn), test_insn, &num_clobbers);
>- if (icode < 0)
>- return false;
>-
>- if (num_clobbers > 0 && added_clobbers_hard_reg_p (icode))
>- return false;
>-
>- if (targetm.cannot_copy_insn_p && targetm.cannot_copy_insn_p
>(test_insn))
>- return false;
>-
>- return true;
>+
>+ /* If the test insn is valid and doesn't need clobbers, and the
>target also
>+ has no objections, we're good. */
>+ if (icode >= 0
>+ && (num_clobbers == 0 || !added_clobbers_hard_reg_p (icode))
>+ && ! (targetm.cannot_copy_insn_p
>+ && targetm.cannot_copy_insn_p (test_insn)))
>+ can_assign = true;
>+
>+ /* Make sure test_insn doesn't have any pointers into GC space. */
>+ SET_SRC (PATTERN (test_insn)) = NULL_RTX;
>+
>+ return can_assign;
> }
>
>/* Return nonzero if the operands of expression X are unchanged from
>the