Go to file
Joseph Myers 3320319ede tree-nested: Do not inline or clone functions with nested functions with VM return type [PR117164]
Bug 117164 is an ICE on an existing test with -std=gnu23 involving a
nested function returning a variable-size structure (and I think the
last bug needing to be resolved before switching to -std=gnu23 as the
default, as without fixing this would be a clear regression from a
change in default).

The problem is a GIMPLE verification failure where (after type
remapping from inlining / cloning) the return type of the function no
longer exactly matches the type to which it is assigned (these types
use structural equality, which means GIMPLE verification can't use
TYPE_CANONICAL and expects an exact match).  Specifically, the nested
function itself is *not* inlined (the -fno-inline-small-functions in
the original test nested-func-12.c, I think, or the noinline attribute
in some of my variant tests), but the function containing it is either
cloned (the --param ipa-cp-eval-threshold=0 in the original test) or
inlined.  (I'm not sure what role -fno-guess-branch-probability plays
in getting the right situation for the ICE; maybe affecting when
inlining or cloning is considered profitable?)

There is in fact existing code in tree-nested.cc to prevent inlining
of a function containing a nested function with variably modified
*argument* types.  I think the same issue of ensuring consistency of
types means such prevention should also apply for a variably modified
return type.  Furthermore, exactly the same problem applies for
cloning for other reasons as it does for inlining.  Thus, change the
logic to include variably modified return types for nested functions
alongside those for arguments of those functions as a reason not to
inline, and also add the noclone attribute in these cases.

Bootstrapped with no regressions for x86-64-pc-linux-gnu.

	PR c/117164

gcc/
	* tree-nested.cc: Include "attribs.h".
	(check_for_nested_with_variably_modified): Also return true for
	variably modified return type.
	(create_nesting_tree): If check_for_nested_with_variably_modified
	returns true, also add noclone attribute.

gcc/testsuite/
	* gcc.dg/nested-func-13.c, gcc.dg/nested-func-14.c:
	gcc.dg/nested-func-15.c, gcc.dg/nested-func-16.c,
	gcc.dg/nested-func-17.c: New tests.
2024-11-15 14:08:42 +00:00
.forgejo
.github
c++tools
config
contrib Daily bump. 2024-11-14 17:20:15 +00:00
fixincludes
gcc tree-nested: Do not inline or clone functions with nested functions with VM return type [PR117164] 2024-11-15 14:08:42 +00:00
gnattools
gotools
include
INSTALL
libada
libatomic Daily bump. 2024-11-14 17:20:15 +00:00
libbacktrace
libcc1
libcody
libcpp c: Add _Decimal64x support 2024-11-15 08:43:48 +01:00
libdecnumber
libffi
libgcc Daily bump. 2024-11-14 17:20:15 +00:00
libgfortran
libgm2
libgo
libgomp Daily bump. 2024-11-14 17:20:15 +00:00
libgrust
libiberty
libitm
libobjc
libphobos
libquadmath
libsanitizer libsanitizer: Update LOCAL_PATCHES 2024-11-12 21:59:49 +08:00
libssp
libstdc++-v3 Daily bump. 2024-11-15 00:16:23 +00:00
libvtv
lto-plugin
maintainer-scripts
zlib
.b4-config
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
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.