Skip to content

Commit

Permalink
Make things easier to profile
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Oct 24, 2024
1 parent 2d8144a commit 80cf050
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,6 @@ rustc_queries! {
/// and with extra transforms applied.
query build_codegen_mir(key: ty::Instance<'tcx>) -> &'tcx mir::Body<'tcx> {
desc { |tcx| "finalizing codegen MIR for `{}`", tcx.def_path_str_with_args(key.def_id(), key.args) }
cache_on_disk_if { true }
arena_cache
}

Expand Down
25 changes: 20 additions & 5 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,12 +690,27 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> {
}

pub fn build_codegen_mir<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Body<'tcx> {
#[inline(never)]
fn clone_mir<'tcx>(body: &Body<'tcx>) -> Body<'tcx> {
body.clone()
}
#[inline(never)]
fn monomorphize_mir<'tcx>(
tcx: TyCtxt<'tcx>,
instance: Instance<'tcx>,
body: Body<'tcx>,
) -> Body<'tcx> {
instance.instantiate_mir_and_normalize_erasing_regions(
tcx,
ty::ParamEnv::reveal_all(),
ty::EarlyBinder::bind(body),
)
}

let body = tcx.instance_mir(instance.def);
let mut body = instance.instantiate_mir_and_normalize_erasing_regions(
tcx,
ty::ParamEnv::reveal_all(),
ty::EarlyBinder::bind(body.clone()),
);
let body = clone_mir(body);
let mut body = monomorphize_mir(tcx, instance, body);

pm::run_passes(
tcx,
&mut body,
Expand Down

0 comments on commit 80cf050

Please sign in to comment.