Hi, this patch fixes a problem when -fno-guess-branch-probability is inlined into expanded thunk. When inlining, the profile status needs to be dropped to lowest common one (well in theory we can avoid that when callee has only one BB or so).
Index: ChangeLog =================================================================== --- ChangeLog (revision 249837) +++ ChangeLog (working copy) @@ -1,3 +1,8 @@ +2017-06-29 Jan Hubicka <hubi...@ucw.cz> + + PR ipa/81261 + * tree-inline.c (expand_call_inline): Combine profile statuses. + 2017-06-30 Richard Biener <rguent...@suse.de> * graph.c (draw_cfg_node_succ_edges): Fix broken dot syntax. Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 249837) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2017-06-29 Jan Hubicka <hubi...@ucw.cz> + + PR ipa/81261 + * g++.dg/ipa/pr81261.C: New testcase. + 2017-06-30 Nathan Sidwell <nat...@acm.org> PR c++/81229 Index: testsuite/g++.dg/ipa/pr81261.C =================================================================== --- testsuite/g++.dg/ipa/pr81261.C (revision 0) +++ testsuite/g++.dg/ipa/pr81261.C (working copy) @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-guess-branch-probability" } */ + +struct CBase { + virtual void BaseFunc () {} +}; + +struct MMixin { + virtual void * MixinFunc (int, void *) = 0; +}; + +struct CExample: CBase, public MMixin +{ + void *MixinFunc (int arg, void *arg2) + { + if (arg != 1 || arg2) + return 0; + return this; + } +}; + +void *test (MMixin & anExample) +{ + return anExample.MixinFunc (1, 0); +} + +int main () +{ + CExample c; + return (test (c) != &c); +} Index: tree-inline.c =================================================================== --- tree-inline.c (revision 249837) +++ tree-inline.c (working copy) @@ -4650,6 +4650,9 @@ expand_call_inline (basic_block bb, gimp else id->dst_simt_vars = NULL; + if (profile_status_for_fn (id->src_cfun) == PROFILE_ABSENT) + profile_status_for_fn (dst_cfun) = PROFILE_ABSENT; + /* If the src function contains an IFN_VA_ARG, then so will the dst function after inlining. Likewise for IFN_GOMP_USE_SIMT. */ prop_mask = PROP_gimple_lva | PROP_gimple_lomp_dev;