Closed
Description
There are a few attributes, like #[inline]
, #[cold]
, and #[target_feature]
, that would profit from being turned into a query:
- directly accessing the
ast::Attribute
will lead to a dependency edge to HIR which is brittle because of spans, - at least #[inline] is searched for a few times, so caching might be good.
The attributes in question are listed in trans::attributes::from_fn_attrs()
:
rust/src/librustc_trans/attributes.rs
Lines 97 to 132 in 27ede55
A query could return a TransFnAttrs
value that looks like:
struct TransFnAttrs {
inline: InlineAttr, // from syntax::attr
flags: TransFnAttrFlags,
target_features: Symbol,
}
bitflags! {
pub struct TransFnAttrFlags: u8 {
const COLD = 0b0000_0001;
const ALLOCATOR = 0b0000_0010;
const UNWIND = 0b0000_0100;
const RUSTC_ALLOCATOR_NOUNWIND = 0b0000_1000;
const NAKED = 0b0001_0000;
}
}
The syntax::attr::{find_inline_attr, requests_inline}
should be replaced by this new query then.
The ultimate goal of this refactoring is to reduce the number of false positives during incr. comp. cache invalidation by providing a "firewall" between HIR and the compile_codegen_unit
query.