diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 33775ac..9f6c7e5 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -3060,7 +3060,8 @@ mcf.o : mcf.c profile.h $(CONFIG_H) $(SYSTEM_H) $(TM_H) coretypes.h \
    $(BASIC_BLOCK_H) langhooks.h $(GCOV_IO_H) $(TREE_H) 
 tree-profile.o : tree-profile.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(TM_H) $(TARGET_H) $(TREE_H) $(FLAGS_H) $(FUNCTION_H) \
-   $(BASIC_BLOCK_H) $(DIAGNOSTIC_CORE_H) $(COVERAGE_H) $(TREE_H) value-prof.h $(TREE_DUMP_H) \
+   $(BASIC_BLOCK_H) $(DIAGNOSTIC_CORE_H) $(COVERAGE_H) $(TREE_H) \
+   value-prof.h $(TREE_DUMP_H) ipa-inline.h \
    $(TREE_PASS_H) $(TREE_FLOW_H) $(TIMEVAR_H) gt-tree-profile.h $(CGRAPH_H)
 value-prof.o : value-prof.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
    $(BASIC_BLOCK_H) hard-reg-set.h profile.h value-prof.h $(EXPR_H) $(FLAGS_H) \
diff --git a/gcc/ipa.c b/gcc/ipa.c
index 09351a7..f5cce1b 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -449,6 +449,11 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, FILE *file)
   verify_symtab ();
 #endif
 
+  /* If we removed something, perhaps profile could be improved.  */
+  if (changed && optimize && inline_edge_summary_vec)
+    FOR_EACH_DEFINED_FUNCTION (node)
+      cgraph_propagate_frequency (node);
+
   return changed;
 }
 
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index dfd0ef0..b90ab92 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -42,6 +42,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "timevar.h"
 #include "value-prof.h"
 #include "cgraph.h"
+#include "ipa-inline.h"
 #include "profile.h"
 #include "target.h"
 
@@ -357,7 +358,7 @@ gimple_gen_ic_profiler (histogram_value value, unsigned tag, unsigned base)
    beginning of every possible called function.
   */
 
-void
+bool
 gimple_gen_ic_func_profiler (void)
 {
   struct cgraph_node * c_node = cgraph_get_node (current_function_decl);
@@ -366,7 +367,7 @@ gimple_gen_ic_func_profiler (void)
   tree tree_uid, cur_func, counter_ptr, ptr_var, void0;
 
   if (cgraph_only_called_directly_p (c_node))
-    return;
+    return false;
 
   gimple_init_edge_profiler ();
 
@@ -394,6 +395,7 @@ gimple_gen_ic_func_profiler (void)
   void0 = build_int_cst (build_pointer_type (void_type_node), 0);
   stmt2 = gimple_build_assign (ic_void_ptr_var, void0);
   gsi_insert_before (&gsi, stmt2, GSI_SAME_STMT);
+  return true;
 }
 
 /* Output instructions as GIMPLE trees for code to find the most common value
@@ -462,6 +464,7 @@ static unsigned int
 tree_profiling (void)
 {
   struct cgraph_node *node;
+  bool gen_ic_func_profiler;
 
   /* Don't profile functions produced at destruction time, particularly
      the gcov datastructure initializer.  Don't profile if it has been
@@ -472,6 +475,8 @@ tree_profiling (void)
 
   init_node_map();
 
+  gen_ic_func_profiler = false;
+
   FOR_EACH_DEFINED_FUNCTION (node)
     {
       if (!gimple_has_body_p (node->symbol.decl))
@@ -495,7 +500,7 @@ tree_profiling (void)
 
       if (! flag_branch_probabilities
 	  && flag_profile_values)
-	gimple_gen_ic_func_profiler ();
+	gen_ic_func_profiler |= gimple_gen_ic_func_profiler ();
 
       if (flag_branch_probabilities
 	  && flag_profile_values
@@ -567,6 +572,10 @@ tree_profiling (void)
       pop_cfun ();
     }
 
+  /* Clear stale inline summary.  */
+  if (gen_ic_func_profiler)
+    inline_free_summary ();
+
   del_node_map();
   return 0;
 }
diff --git a/gcc/value-prof.h b/gcc/value-prof.h
index b7215b8..b083c29 100644
--- a/gcc/value-prof.h
+++ b/gcc/value-prof.h
@@ -96,7 +96,7 @@ extern void gimple_gen_interval_profiler (histogram_value, unsigned, unsigned);
 extern void gimple_gen_pow2_profiler (histogram_value, unsigned, unsigned);
 extern void gimple_gen_one_value_profiler (histogram_value, unsigned, unsigned);
 extern void gimple_gen_ic_profiler (histogram_value, unsigned, unsigned);
-extern void gimple_gen_ic_func_profiler (void);
+extern bool gimple_gen_ic_func_profiler (void);
 extern void gimple_gen_const_delta_profiler (histogram_value,
 					     unsigned, unsigned);
 extern void gimple_gen_average_profiler (histogram_value, unsigned, unsigned);
