This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Implement ggc_trim
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc-patches at gcc dot gnu dot org, rguenther at suse dot de, mliska at suse dot cz, mjambor at suse dot cz
- Date: Fri, 18 Oct 2019 19:20:17 +0200
- Subject: Re: Implement ggc_trim
- References: <20191011070353.c5d7qbrxliw3vkom@kam.mff.cuni.cz>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Oct 11, 2019 at 09:03:53AM +0200, Jan Hubicka wrote:
> Bootstrapped/regtested x86_64-linux, OK?
>
> * ggc-page.c (release_pages): Output statistics when !quiet_flag.
> (ggc_collect): Dump later to not interfere with release_page dump.
> (ggc_trim): New function.
> * ggc-none.c (ggc_trim): New.
>
> * lto.c (lto_wpa_write_files): Call ggc_trim.
> @@ -1152,10 +1156,20 @@ release_pages (void)
> *gp = g->next;
> G.bytes_mapped -= g->alloc_size;
> free (g->allocation);
> + n1 += g->alloc_size;
> }
> else
> gp = &g->next;
> #endif
This broke !defined(USING_MMAP) support, the second g->alloc_size read
is after the memory containing *g is freed.
Fixed thusly, tested with #undef USING_MMAP in the file (without the patch
self-test ICEs, with it succeeds), committed to trunk as obvious.
2019-10-18 Jakub Jelinek <jakub@redhat.com>
PR middle-end/92153
* ggc-page.c (release_pages): Read g->alloc_size before free rather
than after it.
--- gcc/ggc-page.c.jj 2019-10-11 14:10:44.987386981 +0200
+++ gcc/ggc-page.c 2019-10-18 19:13:59.458085610 +0200
@@ -1155,8 +1155,8 @@ release_pages (void)
{
*gp = g->next;
G.bytes_mapped -= g->alloc_size;
- free (g->allocation);
n1 += g->alloc_size;
+ free (g->allocation);
}
else
gp = &g->next;
Jakub