* lto-partition.c (lto_balanced_map): Watch overflow.
authorJan Hubicka <hubicka@ucw.cz>
Fri, 23 Feb 2018 18:18:07 +0000 (19:18 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 23 Feb 2018 18:18:07 +0000 (18:18 +0000)
From-SVN: r257939

gcc/lto/ChangeLog
gcc/lto/lto-partition.c

index 62fec49838053a33aac14b75dbfd903cd6cf3e0a..55013a81bb25b5ba2eb8cd771d3a0ccd5272240e 100644 (file)
@@ -1,3 +1,7 @@
+2018-02-08  Jan Hubicka  <hubicka@ucw.cz>
+
+       * lto-partition.c (lto_balanced_map): Watch overflow.
+
 2018-02-08  Jan Hubicka  <hubicka@ucw.cz>
 
        PR ipa/81360
index 6055dad99b505da9e875c1c37ca12d788c59a6ac..60daafdf375089e9fba2ca09e9fdd4e8d838a359 100644 (file)
@@ -757,7 +757,8 @@ lto_balanced_map (int n_lto_partitions, int max_partition_size)
          if (npartitions < n_lto_partitions)
            partition_size = total_size / (n_lto_partitions - npartitions);
          else
-           partition_size = INT_MAX;
+           /* Watch for overflow.  */
+           partition_size = INT_MAX / 16;
 
          if (partition_size < PARAM_VALUE (MIN_PARTITION_SIZE))
            partition_size = PARAM_VALUE (MIN_PARTITION_SIZE);