Missed enum layout optimization depending on enum variant field reordering #125630
Labels
A-layout
Area: Memory layout of types
C-optimization
Category: An issue highlighting optimization opportunities or PRs implementing such
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
rustc fails to optimize the enum Layout of
V1
andV2
of the (real world) example typeLazyRwLockGuard
to 24 bytes.In case of
V1
, this might be be due to #101567.But the case of
V2
seems to be a separate issue, as it is identical toV3
(which is optimized correctly), except for the ordering of the fields inside theRead
enum variant.(For clarity,
RwLockReadGuard
andRwLockWriteGuard
each use 16 bytes and contain a niche).godbolt repro
stackoverflow question
The text was updated successfully, but these errors were encountered: