Skip to content

Commit

Permalink
Add partitioning -Z option to control which partitioning scheme is used
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleywiser committed Aug 22, 2020
1 parent 5d501f9 commit 98b943e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/librustc_mir/monomorphize/partitioning/mod.rs
Expand Up @@ -135,8 +135,16 @@ trait Partitioner<'tcx> {
);
}

fn get_partitioner<'tcx>() -> Box<dyn Partitioner<'tcx>> {
Box::new(default::DefaultPartitioning)
fn get_partitioner<'tcx>(tcx: TyCtxt<'tcx>) -> Box<dyn Partitioner<'tcx>> {
let strategy = match &tcx.sess.opts.debugging_opts.cgu_partitioning_strategy {
None => "default",
Some(s) => &s[..],
};

match strategy {
"default" => Box::new(default::DefaultPartitioning),
_ => tcx.sess.fatal("unknown partitioning strategy"),
}
}

pub fn partition<'tcx>(
Expand All @@ -147,7 +155,7 @@ pub fn partition<'tcx>(
) -> Vec<CodegenUnit<'tcx>> {
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning");

let mut partitioner = get_partitioner();
let mut partitioner = get_partitioner(tcx);
// In the first step, we place all regular monomorphizations into their
// respective 'home' codegen unit. Regular monomorphizations are all
// functions and statics defined in the local crate.
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_session/options.rs
Expand Up @@ -807,6 +807,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"select which borrowck is used (`mir` or `migrate`) (default: `migrate`)"),
borrowck_stats: bool = (false, parse_bool, [UNTRACKED],
"gather borrowck statistics (default: no)"),
cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
"the codegen unit partitioning strategy to use"),
chalk: bool = (false, parse_bool, [TRACKED],
"enable the experimental Chalk-based trait solving engine"),
codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
Expand Down

0 comments on commit 98b943e

Please sign in to comment.