From patchwork Tue Nov 6 21:11:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: New badness metric for inliner Date: Tue, 06 Nov 2012 11:11:44 -0000 From: Jan Hubicka X-Patchwork-Id: 197544 Message-Id: <20121106211143.GA22247@kam.mff.cuni.cz> To: David Miller Cc: hubicka@ucw.cz, gcc-patches@gcc.gnu.org > From: Jan Hubicka > Date: Tue, 6 Nov 2012 22:01:27 +0100 > > > Hmm, this is obvoiusly wrong. All the caller time computation should be capped > > to MAX_TIME that should be safe from overflows. > > They are not capped to MAX_TIME. > > They are capped to MAX_TIME * INLINE_TIME_SCALE which is > 1000000000. Right and that is why they need to be capped after every addition. (while writting the code it did not have the INLINE_TIME_SCALE factor yet and I concluded I do not need to do capping because there are at most 32 additions). I noticed there is one extra place with this problem, so I fixed it, too. The attached patch fixes the testcase, so I comitted it as obvious. Hope it will fix the bootstrap for you. I did not hit this because my bootstrap did not have graphite enabled due to lack of proper support libraries. Comitted as obvious. * ipa-inline-analysis.c (estimate_function_body_sizes, inline_update_overall_summary): Cap time calculations. Index: ipa-inline-analysis.c =================================================================== --- ipa-inline-analysis.c (revision 193246) +++ ipa-inline-analysis.c (working copy) @@ -2442,6 +2442,8 @@ estimate_function_body_sizes (struct cgr { time += this_time; size += this_size; + if (time > MAX_TIME * INLINE_TIME_SCALE) + time = MAX_TIME * INLINE_TIME_SCALE; } /* We account everything but the calls. Calls have their own @@ -3323,7 +3325,11 @@ inline_update_overall_summary (struct cg info->size = 0; info->time = 0; for (i = 0; VEC_iterate (size_time_entry, info->entry, i, e); i++) - info->size += e->size, info->time += e->time; + { + info->size += e->size, info->time += e->time; + if (info->time > MAX_TIME * INLINE_TIME_SCALE) + info->time = MAX_TIME * INLINE_TIME_SCALE; + } estimate_calls_size_and_time (node, &info->size, &info->time, NULL, ~(clause_t)(1 << predicate_false_condition), NULL, NULL, NULL);