On 9/27/19 9:13 AM, luoxhu wrote: > Thanks for your time of so many round of reviews.
You're welcome. One last request would be please to make gimple_ic_transform a void function. See attached patch. I'll remind the patch today to Honza. Thanks, Martin
diff --git a/gcc/value-prof.c b/gcc/value-prof.c index 5f095d848f0..7cb99376c69 100644 --- a/gcc/value-prof.c +++ b/gcc/value-prof.c @@ -107,7 +107,7 @@ static bool gimple_divmod_fixed_value_transform (gimple_stmt_iterator *); static bool gimple_mod_pow2_value_transform (gimple_stmt_iterator *); static bool gimple_mod_subtract_transform (gimple_stmt_iterator *); static bool gimple_stringops_transform (gimple_stmt_iterator *); -static bool gimple_ic_transform (gimple_stmt_iterator *); +static void gimple_ic_transform (gimple_stmt_iterator *); /* Allocate histogram value. */ @@ -617,8 +617,7 @@ gimple_value_profile_transformations (void) if (gimple_mod_subtract_transform (&gsi) || gimple_divmod_fixed_value_transform (&gsi) || gimple_mod_pow2_value_transform (&gsi) - || gimple_stringops_transform (&gsi) - || gimple_ic_transform (&gsi)) + || gimple_stringops_transform (&gsi)) { stmt = gsi_stmt (gsi); changed = true; @@ -629,6 +628,9 @@ gimple_value_profile_transformations (void) gsi = gsi_for_stmt (stmt); } } + + /* The function never thansforms a GIMPLE statement. */ + gimple_ic_transform (&gsi); } } @@ -1411,7 +1413,7 @@ gimple_ic (gcall *icall_stmt, struct cgraph_node *direct_call, LTO stage for later process. Modify code of this indirect call to an if-else structure in ipa-profile finally. */ -static bool +static void gimple_ic_transform (gimple_stmt_iterator *gsi) { gcall *stmt; @@ -1421,17 +1423,17 @@ gimple_ic_transform (gimple_stmt_iterator *gsi) stmt = dyn_cast <gcall *> (gsi_stmt (*gsi)); if (!stmt) - return false; + return; if (gimple_call_fndecl (stmt) != NULL_TREE) - return false; + return; if (gimple_call_internal_p (stmt)) - return false; + return; histogram = gimple_histogram_value_of_type (cfun, stmt, HIST_TYPE_INDIR_CALL); if (!histogram) - return false; + return; count = 0; all = histogram->hvalue.counters[0]; @@ -1440,11 +1442,11 @@ gimple_ic_transform (gimple_stmt_iterator *gsi) { if (!get_nth_most_common_value (NULL, "indirect call", histogram, &val, &count, &all, j)) - return false; + return; /* Minimum probability. should be higher than 25%. */ if (4 * count <= all) - return false; + return; direct_call = find_func_by_profile_id ((int) val); @@ -1459,7 +1461,7 @@ gimple_ic_transform (gimple_stmt_iterator *gsi) "module %T=> %i (will resolve only with LTO)\n", gimple_call_fn (stmt), (int) val); } - return false; + return; } if (!check_ic_target (stmt, direct_call)) @@ -1471,7 +1473,7 @@ gimple_ic_transform (gimple_stmt_iterator *gsi) "transformation skipped because of type mismatch: %G", gimple_call_fn (stmt), direct_call->decl, stmt); gimple_remove_histogram_value (cfun, stmt, histogram); - return false; + return; } if (dump_enabled_p ()) @@ -1485,8 +1487,6 @@ gimple_ic_transform (gimple_stmt_iterator *gsi) count, all); } } - - return false; } /* Return true if the stringop CALL shall be profiled. SIZE_ARG be