@@ -511,9 +511,20 @@ lto_balanced_map (int n_lto_partitions)
varpool_order.qsort (varpool_node_cmp);
/* Compute partition size and create the first partition. */
+ if (PARAM_VALUE (MIN_PARTITION_SIZE) > PARAM_VALUE (MAX_PARTITION_SIZE))
+ fatal_error (input_location, "min partition size cannot be greater than max partition size");
+
partition_size = total_size / n_lto_partitions;
if (partition_size < PARAM_VALUE (MIN_PARTITION_SIZE))
partition_size = PARAM_VALUE (MIN_PARTITION_SIZE);
+ else if (partition_size > PARAM_VALUE (MAX_PARTITION_SIZE))
+ {
+ n_lto_partitions = total_size / PARAM_VALUE (MAX_PARTITION_SIZE);
+ if (total_size % PARAM_VALUE (MAX_PARTITION_SIZE))
+ n_lto_partitions++;
+ partition_size = total_size / n_lto_partitions;
+ }
+
npartitions = 1;
partition = new_partition ("");
if (symtab->dump_file)
@@ -3112,6 +3112,12 @@ do_whole_program_analysis (void)
timevar_pop (TV_WHOPR_WPA);
timevar_push (TV_WHOPR_PARTITIONING);
+
+ if (flag_lto_partition != LTO_PARTITION_BALANCED
+ && PARAM_VALUE (MAX_PARTITION_SIZE) != INT_MAX)
+ fatal_error (input_location, "--param max-lto-partition should only"
+ " be used with balanced partitioning\n");
+
if (flag_lto_partition == LTO_PARTITION_1TO1)
lto_1_to_1_map ();
else if (flag_lto_partition == LTO_PARTITION_MAX)
@@ -1029,6 +1029,11 @@ DEFPARAM (MIN_PARTITION_SIZE,
"Minimal size of a partition for LTO (in estimated instructions).",
1000, 0, 0)
+DEFPARAM (MAX_PARTITION_SIZE,
+ "lto-max-partition",
+ "Maximal size of a partition for LTO (in estimated instructions).",
+ INT_MAX, 0, INT_MAX)
+
/* Diagnostic parameters. */
DEFPARAM (CXX_MAX_NAMESPACES_FOR_DIAGNOSTIC_HELP,