GCC modified for the FreeChainXenon project
Find a file
Jan Hubicka 845bb366ad ipa: fix handling of multiple speculations (PR93318)
This patch started as work to resole Richard's comment on quadratic lookups
in resolve_speculation. While doing it I however noticed multiple problems
in the new speuclative call code which made the patch quite big. In
particular:
 1) Before applying speculation we consider only targets with at lest
    probability 1/2.
    If profile is sane at most two targets can have probability greater or
    equal to 1/2. So the new multi-target speculation code got enabled only
    in very special scenario when there ae precisely two target with precise
    probability 1/2 (which is tested by the single testcase).

    As a conseuqence the multiple target logic got minimal test coverage and
    this made us to miss several ICEs.
 2) Profile updating in profile merging, tree-inline and indirect call
    expansion was wrong which led to inconsistent profiles (as already seen
    on the testcase).
 3) Code responsible to turn speculative call to direct call was broken for
    anything with more than one target.
 4) There were multiple cases where call_site_hash went out of sync which
    eventually leads to an ICE..
 5) Some code expects that all speculative call targets forms a sequence in
    the callee linked list but there is no code to maintain that invariant
    nor a verifier.
Fixing this it became obvious that the current API of speculative_call_info is
not useful because it really builds on fact tht there are precisely three
components (direct call, ref and indirect call) in every speculative call
sequence.  I ended up replacing it with iterator API for direct call
(first_speculative_call_target, next_speculative_call_target) and accessors for
the other coponents updating comment in cgraph.h.

Finally I made the work with call site hash more effetive by updating edge
manipulation to keep them in sequence. So first one can be looked up from the
hash and then they can be iterated by callee.

There are other things that can be improved (for example the speculation should
start with most common target first), but I will try to keep that for next
stage1. This patch is mostly about getting rid of ICE and profile corruption
which is a regression from GCC 9.

gcc/ChangeLog:

	PR lto/93318
	* cgraph.c (cgraph_add_edge_to_call_site_hash): Update call site
	hash only when edge is first within the sequence.
	(cgraph_edge::set_call_stmt): Update handling of speculative calls.
	(symbol_table::create_edge): Do not set target_prob.
	(cgraph_edge::remove_caller): Watch for speculative calls when updating
	the call site hash.
	(cgraph_edge::make_speculative): Drop target_prob parameter.
	(cgraph_edge::speculative_call_info): Remove.
	(cgraph_edge::first_speculative_call_target): New member function.
	(update_call_stmt_hash_for_removing_direct_edge): New function.
	(cgraph_edge::resolve_speculation): Rewrite to new API.
	(cgraph_edge::speculative_call_for_target): New member function.
	(cgraph_edge::make_direct): Rewrite to new API; fix handling of
	multiple speculation targets.
	(cgraph_edge::redirect_call_stmt_to_callee): Likewise; fix updating
	of profile.
	(verify_speculative_call): Verify that targets form an interval.
	* cgraph.h (cgraph_edge::speculative_call_info): Remove.
	(cgraph_edge::first_speculative_call_target): New member function.
	(cgraph_edge::next_speculative_call_target): New member function.
	(cgraph_edge::speculative_call_target_ref): New member function.
	(cgraph_edge;:speculative_call_indirect_edge): New member funtion.
	(cgraph_edge): Remove target_prob.
	* cgraphclones.c (cgraph_node::set_call_stmt_including_clones):
	Fix handling of speculative calls.
	* ipa-devirt.c (ipa_devirt): Fix handling of speculative cals.
	* ipa-fnsummary.c (analyze_function_body): Likewise.
	* ipa-inline.c (speculation_useful_p): Use new speculative call API.
	* ipa-profile.c (dump_histogram): Fix formating.
	(ipa_profile_generate_summary): Watch for overflows.
	(ipa_profile): Do not require probablity to be 1/2; update to new API.
	* ipa-prop.c (ipa_make_edge_direct_to_target): Update to new API.
	(update_indirect_edges_after_inlining): Update to new API.
	* ipa-utils.c (ipa_merge_profiles): Rewrite merging of speculative call
	profiles.
	* profile-count.h: (profile_probability::adjusted): New.
	* tree-inline.c (copy_bb): Update to new speculative call API; fix
	updating of profile.
	* value-prof.c (gimple_ic_transform): Rename to ...
	(dump_ic_profile): ... this one; update dumping.
	(stream_in_histogram_value): Fix formating.
	(gimple_value_profile_transformations): Update.

gcc/testsuite/ChangeLog:

	* g++.dg/tree-prof/indir-call-prof.C: Update template.
	* gcc.dg/tree-prof/crossmodule-indircall-1.c: Add more targets.
	* gcc.dg/tree-prof/crossmodule-indircall-1a.c: Add more targets.
	* gcc.dg/tree-prof/indir-call-prof.c: Update template.
2020-01-28 20:38:09 +01:00
config gcc: Add new configure options to allow static libraries to be selected 2020-01-27 22:02:35 +00:00
contrib contrib: Change 'remote' for personal branches and add branch creation script 2020-01-24 14:38:16 +00:00
fixincludes Fix missing SCNuMAX defines in inttypes.h on hpux11.[01]* 2020-01-25 12:20:24 -05:00
gcc ipa: fix handling of multiple speculations (PR93318) 2020-01-28 20:38:09 +01:00
gnattools PR81878: fix --disable-bootstrap --enable-languages=ada 2018-11-20 00:07:47 +00:00
gotools libgo: update to Go1.14beta1 2020-01-21 23:53:22 -08:00
include OpenACC 'acc_get_property' cleanup 2020-01-10 23:24:36 +01:00
INSTALL
intl iconv.m4 (AM_ICONV_LINK): Don't overwrite CPPFLAGS. 2018-11-07 15:41:21 -07:00
libada Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libatomic Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libbacktrace Update copyright years. 2020-01-01 12:51:42 +01:00
libcc1 init.c (build_new): Add location_t parameter and use it throughout. 2020-01-07 17:58:18 +00:00
libcpp preprocessor: Make __has_include a builtin macro [PR93452] 2020-01-28 08:02:17 -08:00
libdecnumber Update copyright years. 2020-01-01 12:51:42 +01:00
libffi Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libgcc Add __gcov_indirect_call_profiler_v4_atomic. 2020-01-27 16:20:10 +01:00
libgfortran Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libgo libgo: handle --with-toolexeclibdir=. 2020-01-24 06:33:46 -08:00
libgomp Don't allow mixed component and non-component accesses for OpenACC/Fortran 2020-01-28 06:00:29 -08:00
libhsail-rt Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libiberty [libiberty] output empty args as a pair of quotes 2020-01-23 16:45:24 -03:00
libitm Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libobjc Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
liboffloadmic Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libphobos Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libquadmath Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libsanitizer Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libssp Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
libstdc++-v3 libstdc++: Fix order of changelog entries 2020-01-28 15:20:23 +00:00
libvtv Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
lto-plugin Update copyright years. 2020-01-01 12:51:42 +01:00
maintainer-scripts Replace update_web_docs_libstdcxx_svn with update_web_docs_libstdcxx_git 2020-01-13 21:40:44 +00:00
zlib Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
.dir-locals.el
.gitattributes Add *.md diff=md. 2020-01-15 14:29:53 +01:00
.gitignore Add .clangd and compile_commands.json to .gitignore. 2019-08-28 19:33:28 +00:00
ABOUT-NLS
ar-lib Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
ChangeLog Add *.md diff=md. 2020-01-15 14:29:53 +01:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in MSP430: Add -fno-exceptions multilib 2019-12-11 19:19:50 +00:00
config.guess Update config.sub and config.guess. 2019-09-09 11:14:32 +02:00
config.rpath
config.sub Update config.sub and config.guess. 2019-09-09 11:14:32 +02:00
configure configure.ac: Factor out common cases for compare_exclusions. 2019-12-11 20:59:35 +00:00
configure.ac configure.ac: Factor out common cases for compare_exclusions. 2019-12-11 20:59:35 +00:00
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
depcomp
install-sh
libtool-ldflags
libtool.m4 [ARM/FDPIC v6 02/24] [ARM] FDPIC: Handle arm*-*-uclinuxfdpiceabi in configure scripts 2019-09-10 09:37:00 +02:00
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
MAINTAINERS MAINTAINERS: Update my email address. 2020-01-13 22:10:14 +03:00
Makefile.def Sync top-level change from gdb 2019-06-15 21:32:03 +00:00
Makefile.in Makefile.tpl (HOST_EXPORTS): Add CXX_FOR_BUILD. 2019-08-23 15:37:22 -06:00
Makefile.tpl Makefile.tpl (HOST_EXPORTS): Add CXX_FOR_BUILD. 2019-08-23 15:37:22 -06:00
missing
mkdep
mkinstalldirs
move-if-change
multilib.am Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
README
symlink-tree
test-driver Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
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.