-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #132843 - RalfJung:mono-time-checks, r=<try>
move all mono-time checks into their own folder, and their own query The mono item collector currently also drives two mono-time checks: the lint for "large moves", and the check whether function calls are done with all the required target features. Instead of doing this "inside" the collector, this PR refactors things so that we have a new `rustc_monomorphize::mono_checks` module providing a per-instance query that does these checks. We already have a per-instance query for the ABI checks, so this should be "free" for incremental builds. Non-incremental builds might do a bit more work now since we now have two separate MIR visits (in the collector and the mono-time checks) -- but one of them is cached in case the MIR doesn't change so that seems nice? This slightly changes behavior of the large-move check since the "move_size_spans" deduplication logic now only works per-instance, not globally across the entire collector. We could save some work by sharing the visitor between the ABI checks and the move checks, but let's see perf before doing that work. Cc `@saethlin` since you're also doing some work related to queries and caching and monomorphization, though I don't know if there's any interaction here.
- Loading branch information
Showing
6 changed files
with
135 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//! This implements a single query, `check_mono_fn`, that gets fired for each | ||
//! monomorphization of all functions. This lets us implement monomorphization-time | ||
//! checks in a way that is friendly to incremental compilation. | ||
use rustc_middle::query::Providers; | ||
use rustc_middle::ty::{Instance, TyCtxt}; | ||
|
||
mod abi_check; | ||
mod move_check; | ||
|
||
fn check_mono_item<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) { | ||
let body = tcx.instance_mir(instance.def); | ||
abi_check::check_feature_dependent_abi(tcx, instance, body); | ||
move_check::check_moves(tcx, instance, body); | ||
} | ||
|
||
pub(super) fn provide(providers: &mut Providers) { | ||
*providers = Providers { | ||
check_mono_item, | ||
skip_move_check_fns: move_check::skip_move_check_fns, | ||
..*providers | ||
} | ||
} |
Oops, something went wrong.