This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FDO usability: pid handling


Hi, Insane value profile data may contain indirect call targets with
wrong (corrupted) pids.  r172276 solves the problem when the pid
refers to a bogus target that is still 'alive'. This patch addresses
the issue when the bogus target is already eliminated or pid is too
large.

OK after testing? (SPEC FDO testing is currently blocked by some regressions).

Thanks,

David



2011-04-19  Xinliang David Li  <davidxl@google.com>
	
	* cgraph.h: New function declaration.
	* cgraph.c (cgraph_remove_node): Remove from pid map.
	* value-prof.c (find_func_by_pid): Handle insane pid.
	(cgraph_remove_pid): New function.
Index: cgraph.h
===================================================================
--- cgraph.h	(revision 172721)
+++ cgraph.h	(working copy)
@@ -732,6 +732,8 @@ void compute_inline_parameters (struct c
 cgraph_inline_failed_t cgraph_edge_inlinable_p (struct cgraph_edge *);
 
 
+void cgraph_remove_pid (struct cgraph_node *);
+
 /* Create a new static variable of type TYPE.  */
 tree add_new_static_var (tree type);
 
Index: cgraph.c
===================================================================
--- cgraph.c	(revision 172721)
+++ cgraph.c	(working copy)
@@ -1478,6 +1478,7 @@ cgraph_remove_node (struct cgraph_node *
   cgraph_call_node_removal_hooks (node);
   cgraph_node_remove_callers (node);
   cgraph_node_remove_callees (node);
+  cgraph_remove_pid (node);
   ipa_remove_all_references (&node->ref_list);
   ipa_remove_all_refering (&node->ref_list);
   VEC_free (ipa_opt_pass, heap,
Index: value-prof.c
===================================================================
--- value-prof.c	(revision 172721)
+++ value-prof.c	(working copy)
@@ -1083,13 +1083,35 @@ init_pid_map (void)
 /* Return cgraph node for function with pid */
 
 static inline struct cgraph_node*
-find_func_by_pid (int	pid)
+find_func_by_pid (int pid)
 {
   init_pid_map ();
 
+  if (pid >= cgraph_max_pid)
+    {
+      if (flag_profile_correction)
+        inform (DECL_SOURCE_LOCATION (current_function_decl),
+                "Inconsistent profile: indirect call target (%d) does not exist", pid);
+      else
+        error ("Inconsistent profile: indirect call target (%d) does not exist", pid);
+
+      return NULL;
+    }
+
   return pid_map [pid];
 }
 
+/* Remove a cgraph node N from maps of pids  */
+
+void
+cgraph_remove_pid (struct cgraph_node *n)
+{
+  if (pid_map == NULL || n->pid < 0)
+    return;
+
+  pid_map [n->pid] = NULL;
+}
+
 /* 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]