TEST repository for https://forge.sourceware.org/ experimenting.
  • C++ 30.7%
  • C 30.2%
  • Ada 14.4%
  • D 6.1%
  • Go 5.7%
  • Other 12.4%
Find a file
Patrick Palka c8498d405a c++/reflection: rewrite and memoize consteval_only_p [PR125179]
The TU from this PR exhibits a 40x compile-time slowdown with -freflection
vs without, all due to consteval_only_p which happens to be quite slow on
large intertwined classes due to its recursive walking of TYPE_FIELDS.

This patch firstly rewrites the predicate to use direct recursion instead
of cp_walk_tree so that it's easier to reason about and more closely
mirrors its standard definition at [basic.types.general]/12.

This patch also makes the recursive part of the predicate tri-state, where
the third 'unknown' state corresponds to seeing an incomplete class type
whose consteval-only-ness we don't yet know.

Finally this patch caches the result of the predicate for class types
when the result is known.  When the result is unknown (due to an
incomplete constituent type) then we don't cache so that a subsequent
call to the predicate can try again.

With this patch compile time for said TU is now 1.1x with -freflection
instead of 40x.

	PR c++/125179

gcc/cp/ChangeLog:

	* reflect.cc: (consteval_only_type_r): Remove this cp_walk_tree
	callback and replace with ...
	(consteval_only_walker): ... this recursive memoized
	implementation.
	(consteval_only_p): Define in terms of consteval_only_walker.

Reviewed-by: Jakub Jelinek <jakub@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2026-05-05 20:30:50 -04:00
.forgejo top-level: Rename forgejo sanity checks 2026-02-27 15:08:12 +01:00
.github
c++tools
config Daily bump. 2026-05-06 00:16:29 +00:00
contrib Daily bump. 2026-05-05 00:16:31 +00:00
fixincludes Daily bump. 2026-02-16 00:16:25 +00:00
gcc c++/reflection: rewrite and memoize consteval_only_p [PR125179] 2026-05-05 20:30:50 -04:00
gnattools
gotools
include Daily bump. 2026-02-06 00:16:39 +00:00
INSTALL
libada
libatomic Daily bump. 2026-05-06 00:16:29 +00:00
libbacktrace Daily bump. 2026-05-05 00:16:31 +00:00
libcc1
libcody
libcpp Daily bump. 2026-04-22 00:16:28 +00:00
libdecnumber
libffi Daily bump. 2026-01-30 00:16:31 +00:00
libga68 Daily bump. 2026-03-22 00:16:21 +00:00
libgcc Daily bump. 2026-05-05 00:16:31 +00:00
libgcobol Daily bump. 2026-04-03 00:16:27 +00:00
libgfortran Daily bump. 2026-05-06 00:16:29 +00:00
libgm2 Daily bump. 2026-04-22 00:16:28 +00:00
libgo libgo: cmd/go: use 'gcloud storage cp' instead of 'gsutil cp' 2026-05-02 16:21:35 -07:00
libgomp Daily bump. 2026-05-06 00:16:29 +00:00
libgrust
libiberty Daily bump. 2026-03-06 00:16:27 +00:00
libitm Daily bump. 2026-05-06 00:16:29 +00:00
libobjc
libphobos Daily bump. 2026-04-22 00:16:28 +00:00
libquadmath
libsanitizer Daily bump. 2026-04-30 00:16:31 +00:00
libssp Daily bump. 2026-05-06 00:16:29 +00:00
libstdc++-v3 Daily bump. 2026-05-06 00:16:29 +00:00
libvtv
lto-plugin
maintainer-scripts Daily bump. 2026-04-23 00:16:32 +00:00
zlib
.b4-config
.dir-locals.el
.editorconfig
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2026-05-05 00:16:31 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure [PATCH v2 2/2] build: Set default for CPP_FOR_BUILD environment variable in all cases. 2026-05-01 11:39:05 -06:00
configure.ac [PATCH v2 2/2] build: Set default for CPP_FOR_BUILD environment variable in all cases. 2026-05-01 11:39:05 -06:00
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
depcomp
install-sh
libtool-ldflags
libtool.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
MAINTAINERS MAINTAINERS: Add myself to write after approval 2026-05-04 01:52:08 -05:00
Makefile.def
Makefile.in Makefile.tpl: Implement per-stage GDCFLAGS [PR116975] 2026-02-05 14:25:08 +01:00
Makefile.tpl Makefile.tpl: Implement per-stage GDCFLAGS [PR116975] 2026-02-05 14:25:08 +01:00
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
SECURITY.txt
symlink-tree
test-driver
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.