diff options
| author | Ben Kimock <kimockb@gmail.com> | 2025-08-26 21:08:03 -0400 |
|---|---|---|
| committer | Ben Kimock <kimockb@gmail.com> | 2025-09-05 20:44:49 -0400 |
| commit | ab91a63d403b0105cacd72809cd292a72984ed99 (patch) | |
| tree | f0404f030d8c9fd6a38b082a98fb830eb88d5bfe /compiler | |
| parent | 51ff895062ba60a7cba53f57af928c3fb7b0f2f4 (diff) | |
| download | rust-ab91a63d403b0105cacd72809cd292a72984ed99.tar.gz rust-ab91a63d403b0105cacd72809cd292a72984ed99.zip | |
Ignore intrinsic calls in cross-crate-inlining cost model
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_mir_transform/src/cross_crate_inline.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_mir_transform/src/cross_crate_inline.rs b/compiler/rustc_mir_transform/src/cross_crate_inline.rs index b186c2bd775..df98c07f549 100644 --- a/compiler/rustc_mir_transform/src/cross_crate_inline.rs +++ b/compiler/rustc_mir_transform/src/cross_crate_inline.rs @@ -135,7 +135,16 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { } } } - TerminatorKind::Call { unwind, .. } => { + TerminatorKind::Call { ref func, unwind, .. } => { + // We track calls because they make our function not a leaf (and in theory, the + // number of calls indicates how likely this function is to perturb other CGUs). + // But intrinsics don't have a body that gets assigned to a CGU, so they are + // ignored. + if let Some((fn_def_id, _)) = func.const_fn_def() + && self.tcx.has_attr(fn_def_id, sym::rustc_intrinsic) + { + return; + } self.calls += 1; if let UnwindAction::Cleanup(_) = unwind { self.landing_pads += 1; |
