Fix integer overflow when scaling counts in inliner

Submitted by Jan Hubicka on Aug. 31, 2013, 1:34 p.m.

Details

Message ID 20130831133415.GC12966@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka Aug. 31, 2013, 1:34 p.m.
Hi,
PPC64 lto profiledbootstrap failes because counts get negative in iteger scalling.
Because of lost comdat samples, we end up with function called twice being
inlinined into an call happening few thousdand times.  gcov_scale is then large
and apply_scale should not truncate it to 32bit.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

Patch hide | download patch | download mbox

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 202127)
+++ ChangeLog	(working copy)
@@ -1,3 +1,7 @@ 
+2013-08-31  Jan Hubicka  <jh@suse.cz>
+
+	* basic-block.h (apply_scale): Make scale parmeter gcov_type.
+
 2013-08-31  Uros Bizjak  <ubizjak@gmail.com>
 
 	* config/alpha/alpha.c (alpha_emit_conditional_move): Update
Index: basic-block.h
===================================================================
--- basic-block.h	(revision 202100)
+++ basic-block.h	(working copy)
@@ -958,7 +958,7 @@  combine_probabilities (int prob1, int pr
    constrained to be < REG_BR_PROB_BASE.  */
 
 static inline gcov_type
-apply_scale (gcov_type freq, int scale)
+apply_scale (gcov_type freq, gcov_type scale)
 {
   return RDIV (freq * scale, REG_BR_PROB_BASE);
 }