traits::select: quickly filter out predicates from other traits
this improves most pre-trans passes's performance by ~1%.
That missed the spring cleaning PR because I wanted to ship it.
r? @eddyb
cache dtorck constraints on ADTs
This avoids visiting the fields of all structs multiple times, improving item-bodies checking time by 10% (!).
Not sure whether we want this in 1.18 or 1.19. It's a big-ish patch, but the 10% win is very tempting.
r? @eddyb
rustc: generalize monomorphic_const_eval to polymorphic constants.
With the addition of `Substs` to the query key, we can now evaluate *and cache* polymorphic constants.
Fixes#23898 by replacing the crippled explicit-discriminant-only local-crate-only `lookup_variant_by_id` with `ConstVal::Variant` which can describe variants irrespective of their discriminant.
Fixes#41394 by fixing #23898 (for the original testcase) and by not looping past the first discriminant.
In some cases (e.g. <[int-var] as Add<[int-var]>>), selection can turn up
a large number of candidates. Bailing out early avoids O(n^2) performance.
This improves item-type checking time by quite a bit, resulting in ~2% of total
time-to-typeck.
this avoids parsing item attributes on each call to `item_attrs`, which takes
off 33% (!) of translation time and 50% (!) of trans-item collection time.
That method is *incredibly* hot, so this ends up saving 10% of trans
time.
BTW, we really should be doing dependency tracking there - and possibly be
taking the respective perf hit (got to find a way to make DTMs fast), but
`layout_cache` is a non-dep-tracking map.
Refactor trans some more to pave way for incremental compilation
Various refactorings paving the way for the newer approach to incremental compilation (And, in particular, to "query-ifying" trans). My partial goal is to remove `SharedCrateContext`; this PR gets about as far as I can easily get before starting to really want the red/green algorithm.
r? @eddyb
cc @michaelwoerister
Implementation of repr struct alignment RFC 1358.
The main changes around rustc::ty::Layout::struct:
* Added abi_align field which stores abi alignment before repr align is applied
* align field contains transitive repr alignment
* Added padding vec which stores padding required after fields
The main user of this information is rustc_trans::adt::struct_llfields
which determines the LLVM fields to be used by LLVM, including padding
fields.
A possible future optimisation would be to put the padding Vec in an Option, since it will be unused unless you are using repr align.
Don't panic if an attribute macro fails to resolve at crate root
Adds temporary regression test; this ideally should work as-is (#41430)
Closes#41211
r? @jseyfried