I was trying to debug a compiler crash while compiling a program with auto-fdo enabled during which the compiler crashed. I could triage the bug to this small case. The issue here is that ssa is not in a valid form at this point and the compiler analyzes a function for inlining. diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index 5d99887..d76f396 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -128,6 +128,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-utils.h" #include "cilk.h" #include "cfgexpand.h" +#include "tree-ssa.h" /* Estimate runtime of function can easilly run into huge numbers with many nested loops. Be sure we can compute time * INLINE_SIZE_SCALE * 2 in an @@ -2506,6 +2507,7 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) <0,2>. */ basic_block bb; struct function *my_function = DECL_STRUCT_FUNCTION (node->decl); + verify_ssa (false, true); int freq; struct inline_summary *info = inline_summaries->get (node); struct predicate bb_predicate; Configured with: ../configure --prefix=../install-crash --enable-shared --enable-static --target=arm-foo-linux-gnueabihf --with-sysroot=/compiler/tools/cross/arm-foo-linux-gnueabihf/gcc-5.1/2015-04-22-222321-2c9bf40-release-5.1/arm-foo-linux-gnueabihf/sysroot --disable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --with-gmp=/compiler/tools/cross/arm-foo-linux-gnueabihf/gcc-5.1/2015-04-22-222321-2c9bf40-release-5.1 --with-mpfr=/compiler/tools/cross/arm-foo-linux-gnueabihf/gcc-5.1/2015-04-22-222321-2c9bf40-release-5.1 --enable-target-optspace --disable-libquadmath --enable-tls --disable-libmudflap --enable-threads --with-mpc=/compiler/tools/cross/arm-foo-linux-gnueabihf/gcc-5.1/2015-04-22-222321-2c9bf40-release-5.1 --disable-decimal-float --enable-languages=c,c++,lto --with-build-time-tools=/compiler/tools/cross/arm-foo-linux-gnueabihf/gcc-5.1/2015-04-22-222321-2c9bf40-release-5.1/arm-foo-linux-gnueabihf/bin --disable-libgomp --with-pkgversion='Built at foo from commit SHA:2c9bf40, Rev:222321' --with-bugurl=foo+cc@samsung.com --with-abi=aapcs-linux --with-cpu=cortex-a15 --with-fpu=neon --with-float=hard --with-mode=arm --disable-bootstrap --enable-languages=c,c++ Thread model: posix The compiler crashes like this: ../../../libgcc/config/arm/unwind-arm.c: In function ‘__gnu_unwind_pr_common’: ../../../libgcc/config/arm/unwind-arm.c:511:1: error: virtual definition of statement not up-to-date } ^ # .MEM_102 = VDEF <.MEM_97> _103 = _Unwind_decode_typeinfo_ptr.isra.0 (_101); ../../../libgcc/config/arm/unwind-arm.c:511:1: internal compiler error: verify_ssa failed gcc/build-crash/./gcc/xgcc -Bgcc/build-crash/./gcc/ -Bgcc/build-crash/../install-crash/arm-foo-linux-gnueabihf/bin/ -Bgcc/build-crash/../install-crash/arm-foo-linux-gnueabihf/lib/ -isystem gcc/build-crash/../install-crash/arm-foo-linux-gnueabihf/include -isystem gcc/build-crash/../install-crash/arm-foo-linux-gnueabihf/sys-include -g -O2 -g -Os -O2 -g -O2 -g -Os -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -fno-inline -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fPIC -fno-inline -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include -DHAVE_CC_TLS -o unwind-arm.o -MT unwind-arm.o -MD -MP -MF unwind-arm.dep -fexceptions -c ../../../libgcc/config/arm/unwind-arm.c 0xb80500 convert_callers_for_node ../../gcc/tree-sra.c:4940 0xb853cb cgraph_node::call_for_symbol_and_aliases(bool (*)(cgraph_node*, void*), void*, bool) ../../gcc/cgraph.h:3025 0xb853cb convert_callers ../../gcc/tree-sra.c:4955 0xb853cb modify_function ../../gcc/tree-sra.c:5011 0xb8e861 ipa_early_sra ../../gcc/tree-sra.c:5239 0xb8e861 execute ../../gcc/tree-sra.c:5286 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. make[2]: *** [unwind-arm.o] Error 1 make[2]: *** Waiting for unfinished jobs.... 0xc966ab verify_ssa(bool, bool) ../../gcc/tree-ssa.c:1068 0x8ef1d0 estimate_function_body_sizes ../../gcc/ipa-inline-analysis.c:2510 0x8f1f43 compute_inline_parameters(cgraph_node*, bool) ../../gcc/ipa-inline-analysis.c:2973 0xb80500 convert_callers_for_node ../../gcc/tree-sra.c:4940 0xb853cb cgraph_node::call_for_symbol_and_aliases(bool (*)(cgraph_node*, void*), void*, bool) ../../gcc/cgraph.h:3025 0xb853cb convert_callers ../../gcc/tree-sra.c:4955 0xb853cb modify_function ../../gcc/tree-sra.c:5011 0xb8e861 ipa_early_sra ../../gcc/tree-sra.c:5239 0xb8e861 execute ../../gcc/tree-sra.c:5286 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report.
PS: The bootstrap fails after applying this patch and emits the error reported above.
Can you attach preprocessed source for unwind-arm.c?
Created attachment 35457 [details] Preprocesed unwind-arm.i
This patch seems to fix the problem: diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c index ba2d5ab..6bd296a 100644 --- a/gcc/auto-profile.c +++ b/gcc/auto-profile.c @@ -1547,6 +1547,9 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts) static void early_inline () { + /* compute_inline_parameters needs an up to date SSA form. */ + update_ssa (TODO_update_ssa); + compute_inline_parameters (cgraph_node::get (current_function_decl), true); unsigned todo = early_inliner (cfun); if (todo & TODO_update_ssa_any) We have not verified yet which other pass is causing the SSA to be in an inconsistent state: instead of adding a call to update_ssa() at this place, we should have a verify_ssa(), and fix the other pass.
Could you try if the following patch fixes the bug? Thanks, Dehao Index: gcc/auto-profile.c =================================================================== --- gcc/auto-profile.c (revision 223204) +++ gcc/auto-profile.c (working copy) @@ -1470,6 +1470,7 @@ afdo_vpt_for_early_inline (stmt_set *promoted_stmt if (has_vpt) { optimize_inline_calls (current_function_decl); + update_ssa (TODO_update_ssa); return true; }
Your patch did fix the problem. Thanks!
Looks the patch hasn't been applied to trunk. Should I test it and send to ML?
Yes please! This patch also solves the problem I was chasing a week or so ago: https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00067.html I also know that this is ICE-ing on a large proprietary project when I compile it with autoFDO on gcc-5.x and 6.x releases.
In the link in the previous comment, Richi has a similar patch as suggested by Dehao pending review/test/commit: let's close this bug when Richi's patch lands in trunk.
I'm testing the suggested patch.
Author: marxin Date: Wed Apr 19 12:06:35 2017 New Revision: 246996 URL: https://gcc.gnu.org/viewcvs?rev=246996&root=gcc&view=rev Log: Update SSA after AutoPGO early inlining (PR ipa/65972). 2017-04-19 Richard Biener <rguenther@suse.de> PR ipa/65972 * auto-profile.c (afdo_vpt_for_early_inline): Update SSA when needed by AutoPGO. Modified: trunk/gcc/ChangeLog trunk/gcc/auto-profile.c
Fixed on trunk, queued for active branches.
Author: marxin Date: Fri May 26 11:31:52 2017 New Revision: 248503 URL: https://gcc.gnu.org/viewcvs?rev=248503&root=gcc&view=rev Log: Backport r246996 2017-05-26 Martin Liska <mliska@suse.cz> Backport from mainline 2017-04-19 Richard Biener <rguenther@suse.de> PR ipa/65972 * auto-profile.c (afdo_vpt_for_early_inline): Update SSA when needed by AutoPGO. Modified: branches/gcc-6-branch/gcc/ChangeLog branches/gcc-6-branch/gcc/auto-profile.c
Author: marxin Date: Mon May 29 09:13:20 2017 New Revision: 248568 URL: https://gcc.gnu.org/viewcvs?rev=248568&root=gcc&view=rev Log: Backport r246996 2017-05-29 Martin Liska <mliska@suse.cz> Backport from mainline 2017-04-19 Richard Biener <rguenther@suse.de> PR ipa/65972 * auto-profile.c (afdo_vpt_for_early_inline): Update SSA when needed by AutoPGO. Modified: branches/gcc-5-branch/gcc/ChangeLog branches/gcc-5-branch/gcc/auto-profile.c
Fixed on all active branches.