aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-prof.c
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2011-04-11 20:37:57 +0000
committerXinliang David Li <davidxl@gcc.gnu.org>2011-04-11 20:37:57 +0000
commit26e0228f565f3d57769d18fa362a300ff51ba1e7 (patch)
tree8fba1831628ef1da28cb32bae8e55d3e3fe30a06 /gcc/value-prof.c
parent6075765d8c6993df315a8792440673d95741a5e8 (diff)
downloadgcc-26e0228f565f3d57769d18fa362a300ff51ba1e7.zip
gcc-26e0228f565f3d57769d18fa362a300ff51ba1e7.tar.gz
gcc-26e0228f565f3d57769d18fa362a300ff51ba1e7.tar.bz2
sanity check ic target
From-SVN: r172276
Diffstat (limited to 'gcc/value-prof.c')
-rw-r--r--gcc/value-prof.c23
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)
}
}
}
-