Skip to content

Commit 30e8f97

Browse files
committed
Fix cgraph_node::apply_scale
while working on auto-FDO I noticed that we may run into ICE because we inline function with count profile_count::zero to a call site with profile_count::zero. What may go wrong is that the caller has local profile while callee may have IPA profiles. We used to turn all such counts to 0, but that has changed by a short circuit I introducd recently. Fixed thus. * cgraph.cc (cgraph_node::apply_scale): Special case scaling to profile_count::zero (). (cgraph_node::verify_node): Add extra compatibility check.
1 parent 3d1d893 commit 30e8f97

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

gcc/cgraph.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ cgraph_node::make_profile_global0 (profile_quality quality)
250250
void
251251
cgraph_node::apply_scale (profile_count num, profile_count den)
252252
{
253-
if (num == den)
253+
if (num == den && !(num == profile_count::zero ()))
254254
return;
255255

256256
for (cgraph_edge *e = callees; e; e = e->next_callee)
@@ -3763,6 +3763,13 @@ cgraph_node::verify_node (void)
37633763
count.debug ();
37643764
error_found = true;
37653765
}
3766+
if (inlined_to && !e->count.compatible_p (inlined_to->count))
3767+
{
3768+
error ("edge count is not compatible with inlined to function count");
3769+
e->count.debug ();
3770+
count.debug ();
3771+
error_found = true;
3772+
}
37663773
if (!e->indirect_unknown_callee
37673774
|| !e->indirect_info)
37683775
{

0 commit comments

Comments
 (0)