From patchwork Wed Nov 14 23:04:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Fix overflow in ipa-inline seen on profiledbootstrap Date: Wed, 14 Nov 2012 13:04:23 -0000 From: Jan Hubicka X-Patchwork-Id: 199074 Message-Id: <20121114230423.GB12910@kam.mff.cuni.cz> To: gcc-patches@gcc.gnu.org Hi, profiledbootstrap shows bug in edge_badness. With inline hints the growth is no longer limited by small constant and thus multiplying it with overall growth may overlfow. Bootstrapped/regtested & comitted. Honza PR bootstrap/55051 * ipa-inline.c (edge_badness): Improve dumping; fix overflow. Index: ipa-inline.c =================================================================== --- ipa-inline.c (revision 193505) +++ ipa-inline.c (working copy) @@ -850,9 +850,11 @@ edge_badness (struct cgraph_edge *edge, if (dump) { - fprintf (dump_file, " Badness calculation for %s -> %s\n", + fprintf (dump_file, " Badness calculation for %s/%i -> %s/%i\n", xstrdup (cgraph_node_name (edge->caller)), - xstrdup (cgraph_node_name (callee))); + edge->caller->uid, + xstrdup (cgraph_node_name (callee)), + edge->callee->uid); fprintf (dump_file, " size growth %i, time %i ", growth, edge_time); @@ -917,7 +919,7 @@ edge_badness (struct cgraph_edge *edge, { badness = (relative_time_benefit (callee_info, edge, edge_time) * (INT_MIN / 16 / RELATIVE_TIME_BENEFIT_RANGE)); - badness /= (growth * MAX (1, callee_info->growth)); + badness /= (MIN (65536/2, growth) * MIN (65536/2, MAX (1, callee_info->growth))); gcc_checking_assert (badness <=0 && badness >= INT_MIN / 16); if ((hints & (INLINE_HINT_indirect_call | INLINE_HINT_loop_iterations