Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid duplicating code for each query #69808

Merged
merged 9 commits into from
May 2, 2020
9 changes: 8 additions & 1 deletion src/librustc_query_system/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ enum QueryResult<CTX: QueryContext> {
}

impl<CTX: QueryContext, C: QueryCache> QueryState<CTX, C> {
#[inline(always)]
pub fn iter_results<R>(
&self,
f: impl for<'a> FnOnce(
Expand All @@ -89,6 +90,7 @@ impl<CTX: QueryContext, C: QueryCache> QueryState<CTX, C> {
self.cache.iter(&self.shards, |shard| &mut shard.cache, f)
}

#[inline(always)]
pub fn all_inactive(&self) -> bool {
let shards = self.shards.lock_shards();
shards.iter().all(|shard| shard.active.is_empty())
Expand Down Expand Up @@ -645,6 +647,7 @@ where
/// side-effects -- e.g., in order to report errors for erroneous programs.
///
/// Note: The optimization is only available during incr. comp.
#[inline(never)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the #[inline(never)] marker here? Did you observe a need for it on some benchmark locally?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(no, your description says your rig is not suitable for local benchmarking, so that cannot be the answer...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember. I can remove it.

fn ensure_query_impl<CTX, C>(
tcx: CTX,
state: &QueryState<CTX, C>,
Expand Down Expand Up @@ -681,7 +684,8 @@ fn ensure_query_impl<CTX, C>(
}
}

fn force_query_impl<C, CTX>(
#[inline(never)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same as above, just wondering what prompted this use of #[inline(never)]...)

fn force_query_impl<CTX, C>(
tcx: CTX,
state: &QueryState<CTX, C>,
key: C::Key,
Expand Down Expand Up @@ -715,6 +719,7 @@ fn force_query_impl<C, CTX>(
);
}

#[inline(always)]
pub fn get_query<Q, CTX>(tcx: CTX, span: Span, key: Q::Key) -> Q::Stored
where
Q: QueryDescription<CTX>,
Expand All @@ -726,6 +731,7 @@ where
get_query_impl(tcx, Q::query_state(tcx), span, key, &Q::VTABLE)
}

#[inline(always)]
pub fn ensure_query<Q, CTX>(tcx: CTX, key: Q::Key)
where
Q: QueryDescription<CTX>,
Expand All @@ -735,6 +741,7 @@ where
ensure_query_impl(tcx, Q::query_state(tcx), key, &Q::VTABLE)
}

#[inline(always)]
pub fn force_query<Q, CTX>(tcx: CTX, key: Q::Key, span: Span, dep_node: DepNode<CTX::DepKind>)
where
Q: QueryDescription<CTX>,
Expand Down