return t;
}
+/* Scale function of calls in NODE by ratio ORIG_COUNT/NODE->count. */
+
+void
+scale_ipa_profile_for_fn (struct cgraph_node *node, profile_count orig_count)
+{
+ profile_count to = node->count;
+ profile_count::adjust_for_ipa_scaling (&to, &orig_count);
+ struct cgraph_edge *e;
+
+ for (e = node->callees; e; e = e->next_callee)
+ e->count = e->count.apply_scale (to, orig_count);
+ for (e = node->indirect_calls; e; e = e->next_callee)
+ e->count = e->count.apply_scale (to, orig_count);
+}
/* SRC and DST are going to be merged. Take SRC's profile and merge it into
DST so it is not going to be lost. Possibly destroy SRC's body on the way
else
dst->count = src->count.ipa ();
+ /* First handle functions with no gimple body. */
+ if (dst->thunk.thunk_p || dst->alias
+ || src->thunk.thunk_p || src->alias)
+ {
+ scale_ipa_profile_for_fn (dst, orig_count);
+ return;
+ }
+
/* This is ugly. We need to get both function bodies into memory.
If declaration is merged, we need to duplicate it to be able
to load body that is being replaced. This makes symbol table
/* We can't update CFG profile, but we can scale IPA profile. CFG
will be scaled according to dst->count after IPA passes. */
else
- {
- profile_count to = dst->count;
- profile_count::adjust_for_ipa_scaling (&to, &orig_count);
- struct cgraph_edge *e;
-
- for (e = dst->callees; e; e = e->next_callee)
- e->count = e->count.apply_scale (to, orig_count);
- for (e = dst->indirect_calls; e; e = e->next_callee)
- e->count = e->count.apply_scale (to, orig_count);
- }
+ scale_ipa_profile_for_fn (dst, orig_count);
src->decl = oldsrcdecl;
}