diff options
Diffstat (limited to 'gcc/value-prof.c')
-rw-r--r-- | gcc/value-prof.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/gcc/value-prof.c b/gcc/value-prof.c index 71e889d..b2a082d 100644 --- a/gcc/value-prof.c +++ b/gcc/value-prof.c @@ -1090,6 +1090,25 @@ find_func_by_pid (int pid) return pid_map [pid]; } +/* Perform sanity check on the indirect call target. Due to race conditions, + false function target may be attributed to an indirect call site. If the + call expression type mismatches with the target function's type, expand_call + may ICE. Here we only do very minimal sanity check just to make compiler happy. + Returns true if TARGET is considered ok for call CALL_STMT. */ + +static bool +check_ic_target (gimple call_stmt, struct cgraph_node *target) +{ + location_t locus; + if (gimple_check_call_matching_types (call_stmt, target->decl)) + return true; + + locus = gimple_location (call_stmt); + inform (locus, "Skipping target %s with mismatching types for icall ", + cgraph_node_name (target)); + return false; +} + /* Do transformation if (actual_callee_address == address_of_most_common_function/method) @@ -1268,6 +1287,9 @@ gimple_ic_transform (gimple stmt) if (direct_call == NULL) return false; + if (!check_ic_target (stmt, direct_call)) + return false; + modify = gimple_ic (stmt, direct_call, prob, count, all); if (dump_file) @@ -1748,4 +1770,3 @@ gimple_find_values_to_profile (histogram_values *values) } } } - |