]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #99028 - tmiasko:inline, r=estebank
authorbors <bors@rust-lang.org>
Sat, 9 Jul 2022 04:34:51 +0000 (04:34 +0000)
committerbors <bors@rust-lang.org>
Sat, 9 Jul 2022 04:34:51 +0000 (04:34 +0000)
Miscellaneous inlining improvements

Add `#[inline]` to a few trivial non-generic methods from a perf report
that otherwise wouldn't be candidates for inlining.

compiler/rustc_middle/src/ty/adt.rs
compiler/rustc_middle/src/ty/structural_impls.rs
compiler/rustc_middle/src/ty/sty.rs
compiler/rustc_middle/src/ty/util.rs
compiler/rustc_query_system/src/dep_graph/graph.rs
compiler/rustc_query_system/src/query/job.rs
compiler/rustc_query_system/src/query/mod.rs
compiler/rustc_span/src/lib.rs

index bf7cb610a9097fa3186ca16bd4c40162800ec2c9..4cac767073577af70878b0faaf56fea6db7338f7 100644 (file)
@@ -165,22 +165,27 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
 pub struct AdtDef<'tcx>(pub Interned<'tcx, AdtDefData>);
 
 impl<'tcx> AdtDef<'tcx> {
+    #[inline]
     pub fn did(self) -> DefId {
         self.0.0.did
     }
 
+    #[inline]
     pub fn variants(self) -> &'tcx IndexVec<VariantIdx, VariantDef> {
         &self.0.0.variants
     }
 
+    #[inline]
     pub fn variant(self, idx: VariantIdx) -> &'tcx VariantDef {
         &self.0.0.variants[idx]
     }
 
+    #[inline]
     pub fn flags(self) -> AdtFlags {
         self.0.0.flags
     }
 
+    #[inline]
     pub fn repr(self) -> ReprOptions {
         self.0.0.repr
     }
index 1b4008019fbc58a039d9f73547627a7e2cfdfdb4..391a0a20c9662bd6bfa2e45bdcecb7077c7140bd 100644 (file)
@@ -1126,6 +1126,7 @@ fn has_vars_bound_at_or_above(&self, binder: ty::DebruijnIndex) -> bool {
         self.outer_exclusive_binder() > binder
     }
 
+    #[inline]
     fn has_type_flags(&self, flags: ty::TypeFlags) -> bool {
         self.flags().intersects(flags)
     }
index 03e4319bbf1a8fa1ad1e212d80aadfbf37d3133c..4b51daadabf341dcb7d1d6e5e34df301c9e318e5 100644 (file)
@@ -1315,6 +1315,7 @@ pub fn for_def(def: &ty::GenericParamDef) -> ParamConst {
 impl<'tcx> Deref for Region<'tcx> {
     type Target = RegionKind<'tcx>;
 
+    #[inline]
     fn deref(&self) -> &RegionKind<'tcx> {
         &self.0.0
     }
index 0e581d7f1f7edf3caf17e38cb2adae313e532900..52da6c3a8c03b12f07e11a21e5f5165ebd517bce 100644 (file)
@@ -1042,6 +1042,7 @@ pub fn peel_refs(self) -> Ty<'tcx> {
         ty
     }
 
+    #[inline]
     pub fn outer_exclusive_binder(self) -> ty::DebruijnIndex {
         self.0.outer_exclusive_binder
     }
index 0da42fddd4c1e15e1a44f0f2d3451927d113238d..e7026096e7b503fc7e6c17865daa1ebb1bca0bcb 100644 (file)
@@ -60,6 +60,7 @@ pub enum DepNodeColor {
 }
 
 impl DepNodeColor {
+    #[inline]
     pub fn is_green(self) -> bool {
         match self {
             DepNodeColor::Red => false,
index f1316557c2985f206745ce1cd640c6d41a269832..9f5779194afcb0451ce655d577a1a56f8cc38271 100644 (file)
@@ -84,6 +84,7 @@ pub struct QueryJob {
 
 impl QueryJob {
     /// Creates a new query job.
+    #[inline]
     pub fn new(id: QueryJobId, span: Span, parent: Option<QueryJobId>) -> Self {
         QueryJob {
             id,
@@ -106,6 +107,7 @@ pub(super) fn latch(&mut self) -> QueryLatch {
     ///
     /// This does nothing for single threaded rustc,
     /// as there are no concurrent jobs which could be waiting on us
+    #[inline]
     pub fn signal_complete(self) {
         #[cfg(parallel_compiler)]
         {
index de64ebb62030122e8d696a8db7eb41f3c639ca1d..f698a853d1e7b4023fe88920f5878773735e3088 100644 (file)
@@ -81,6 +81,7 @@ pub struct QuerySideEffects {
 }
 
 impl QuerySideEffects {
+    #[inline]
     pub fn is_empty(&self) -> bool {
         let QuerySideEffects { diagnostics } = self;
         diagnostics.is_empty()
index a329fa153207bbf7e208b5313c86133b70629254..a1f34287a5f36aabdf49a0e51eacf5ea608c713b 100644 (file)
@@ -1603,6 +1603,7 @@ pub fn is_real_file(&self) -> bool {
         self.name.is_real()
     }
 
+    #[inline]
     pub fn is_imported(&self) -> bool {
         self.src.is_none()
     }