Hi David, on 2021/8/19 上午11:26, David Edelsohn via Gcc-patches wrote: > Hi, Martin > > A few PowerPC-specific testcases started failing yesterday on AIX with > a strange failure mode: the compiler runs out of memory. As you may > expect from telling you this in an email reply to your patch, I have > bisected the failure and landed on your commit. I can alternate > between the previous commit and your commit, and the failure > definitely appears with your patch, although I'm unsure how your patch > affected memory allocation in the compiler. Maybe moving the code > changed a type of allocation or some memory no longer is being freed? >
To get rid of GTY variable alloc_object_size_limit looks suspicious, maybe tree objects returned by alloc_max_size after the change are out of GC's tracking? If the suspicion holds, the attached explorative diff may help. BR, Kewen > Previously, compiler bootstrap and all testcases ran with a data size > of 1GB. After your change, the data size required for those > particular testcases jumped to 2GB. > > The testcases are > > gcc/testsuite/gcc.target/powerpc/rlwimi-[012].c > > The failure is > > cc1: out of memory allocating 65536 bytes after a total of 1608979296 > > This seems like a significant memory use regression. Any ideas what happened? > > Thanks, David >
diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 6653e9e2142..9aefed47be8 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2717,7 +2717,7 @@ GTFILES = $(CPPLIB_H) $(srcdir)/input.h $(srcdir)/coretypes.h \ $(srcdir)/sancov.c \ $(srcdir)/ipa-devirt.c \ $(srcdir)/internal-fn.h \ - $(srcdir)/calls.c \ + $(srcdir)/gimple-ssa-warn-access.cc \ $(srcdir)/omp-general.h \ @all_gtfiles@ diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc index f3efe564af0..267ef987edd 100644 --- a/gcc/gimple-ssa-warn-access.cc +++ b/gcc/gimple-ssa-warn-access.cc @@ -2301,6 +2301,9 @@ pass_waccess::gate (function *) || warn_mismatched_new_delete); } +/* The limit set by -Walloc-larger-than=. */ +static GTY(()) tree alloc_object_size_limit; + /* Initialize ALLOC_OBJECT_SIZE_LIMIT based on the -Walloc-size-larger-than= setting if the option is specified, or to the maximum object size if it is not. Return the initialized value. */ @@ -2308,11 +2311,16 @@ pass_waccess::gate (function *) static tree alloc_max_size (void) { + if (alloc_object_size_limit) + return alloc_object_size_limit; + HOST_WIDE_INT limit = warn_alloc_size_limit; if (limit == HOST_WIDE_INT_MAX) limit = tree_to_shwi (TYPE_MAX_VALUE (ptrdiff_type_node)); - return build_int_cst (size_type_node, limit); + alloc_object_size_limit = build_int_cst (size_type_node, limit); + + return alloc_object_size_limit; } /* Diagnose a call EXP to function FN decorated with attribute alloc_size @@ -3328,3 +3336,6 @@ make_pass_warn_access (gcc::context *ctxt) { return new pass_waccess (ctxt); } + +/* Tell the garbage collector about GTY markers in this source file. */ +#include "gt-gimple-ssa-warn-access.h"