Message ID | 4f6e17ca-f02f-4925-8e49-111048235d9a@suse.cz |
---|---|
State | New |
Headers | show |
Series | Handle -fno-guess-branch-probability properly in predict.c (PR ipa/84825). | expand |
On 03/13/2018 01:13 PM, Martin Liška wrote: > Hi. > > This is a fix for situation where we use -fno-guess-branch-probability and fnsplit happens. > > Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. > > Ready for trunk? > Thanks, > Martin > > gcc/ChangeLog: > > 2018-03-13 Martin Liska <mliska@suse.cz> > > PR ipa/84825 > * predict.c (rebuild_frequencies): Handle case when we have > PROFILE_ABSENT, but flag_guess_branch_prob is false. > > gcc/testsuite/ChangeLog: > > 2018-03-13 Martin Liska <mliska@suse.cz> > > * g++.dg/ipa/pr84825.C: New test. > --- > gcc/predict.c | 3 +++ > gcc/testsuite/g++.dg/ipa/pr84825.C | 18 ++++++++++++++++++ > 2 files changed, 21 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/ipa/pr84825.C > > Honza asked about a place where a BB count is set up. It's here: (gdb) bt #0 init_lowered_empty_function (decl=0x7ffff692a700, in_ssa=true, count=...) at ../../gcc/cgraphunit.c:1606 #1 0x0000000000cddde1 in cgraph_node::expand_thunk (this=0x7ffff692f2e0, output_asm_thunks=false, force_gimple_thunk=false) at ../../gcc/cgraphunit.c:1856 #2 0x0000000000cd9e01 in cgraph_node::analyze (this=0x7ffff692f2e0) at ../../gcc/cgraphunit.c:635 #3 0x0000000000cdb85c in analyze_functions (first_time=true) at ../../gcc/cgraphunit.c:1131 #4 0x0000000000ce0510 in symbol_table::finalize_compilation_unit (this=0x7ffff67b0100) at ../../gcc/cgraphunit.c:2691 #5 0x00000000012908d8 in compile_file () at ../../gcc/toplev.c:480 #6 0x00000000012931fd in do_compile () at ../../gcc/toplev.c:2132 #7 0x00000000012934ea in toplev::main (this=0x7fffffffd7de, argc=24, argv=0x7fffffffd8d8) at ../../gcc/toplev.c:2267 #8 0x0000000001f69194 in main (argc=24, argv=0x7fffffffd8d8) at ../../gcc/main.c:39 (gdb) p count.debug() 10000 (estimated locally) $7 = void Martin
> On 03/13/2018 01:13 PM, Martin Liška wrote: > > Hi. > > > > This is a fix for situation where we use -fno-guess-branch-probability and fnsplit happens. > > > > Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. > > > > Ready for trunk? > > Thanks, > > Martin > > > > gcc/ChangeLog: > > > > 2018-03-13 Martin Liska <mliska@suse.cz> > > > > PR ipa/84825 > > * predict.c (rebuild_frequencies): Handle case when we have > > PROFILE_ABSENT, but flag_guess_branch_prob is false. > > > > gcc/testsuite/ChangeLog: > > > > 2018-03-13 Martin Liska <mliska@suse.cz> > > > > * g++.dg/ipa/pr84825.C: New test. > > --- > > gcc/predict.c | 3 +++ > > gcc/testsuite/g++.dg/ipa/pr84825.C | 18 ++++++++++++++++++ > > 2 files changed, 21 insertions(+) > > create mode 100644 gcc/testsuite/g++.dg/ipa/pr84825.C > > > > > > Honza asked about a place where a BB count is set up. It's here: > > (gdb) bt > #0 init_lowered_empty_function (decl=0x7ffff692a700, in_ssa=true, count=...) at ../../gcc/cgraphunit.c:1606 > #1 0x0000000000cddde1 in cgraph_node::expand_thunk (this=0x7ffff692f2e0, output_asm_thunks=false, force_gimple_thunk=false) at ../../gcc/cgraphunit.c:1856 > #2 0x0000000000cd9e01 in cgraph_node::analyze (this=0x7ffff692f2e0) at ../../gcc/cgraphunit.c:635 > #3 0x0000000000cdb85c in analyze_functions (first_time=true) at ../../gcc/cgraphunit.c:1131 > #4 0x0000000000ce0510 in symbol_table::finalize_compilation_unit (this=0x7ffff67b0100) at ../../gcc/cgraphunit.c:2691 > #5 0x00000000012908d8 in compile_file () at ../../gcc/toplev.c:480 > #6 0x00000000012931fd in do_compile () at ../../gcc/toplev.c:2132 > #7 0x00000000012934ea in toplev::main (this=0x7fffffffd7de, argc=24, argv=0x7fffffffd8d8) at ../../gcc/toplev.c:2267 > #8 0x0000000001f69194 in main (argc=24, argv=0x7fffffffd8d8) at ../../gcc/main.c:39 > > (gdb) p count.debug() > 10000 (estimated locally) > $7 = void I see, expand_thunk guesses even when guessing is disabled and we later inline it and that enables ipa-split. Hmm, I guess patch is OK and I will look into cleaning this up next stage1. Honza > > Martin
diff --git a/gcc/predict.c b/gcc/predict.c index b40dec47822..019ff9e44cf 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -3998,6 +3998,9 @@ rebuild_frequencies (void) } else if (profile_status_for_fn (cfun) == PROFILE_READ) update_max_bb_count (); + else if (profile_status_for_fn (cfun) == PROFILE_ABSENT + && !flag_guess_branch_prob) + ; else gcc_unreachable (); timevar_pop (TV_REBUILD_FREQUENCIES); diff --git a/gcc/testsuite/g++.dg/ipa/pr84825.C b/gcc/testsuite/g++.dg/ipa/pr84825.C new file mode 100644 index 00000000000..7ae854e7140 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr84825.C @@ -0,0 +1,18 @@ +/* PR ipa/84658 */ +/* { dg-options "-O3 --param early-inlining-insns=0 -fno-guess-branch-probability" } */ + +struct a; +struct b; +struct c { + virtual a *d(b *); +}; +struct a { + virtual a e(); +}; +struct f { + virtual ~f(); +}; +struct g : f, a {}; +struct b : c, virtual g { + b *d(b *h) { return h; } +} i;