all() causing LLVM bloat #491
Labels
No labels
bug
good first issue
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-bitflags/bitflags#491
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently, bitflags::all() outputs
6 + 20nlines of LLVM IR in debug builds, and8 + 14non release builds, wherenis the number of flags. I first noticed this with wgpu's FeaturesWGPU, which has 58 flags (1166 lines debug, 820 release).The implementation is here:
github.com/bitflags/bitflags@9253889ee9/src/public.rs (L150-L168)If I wrap the function in
const {}then the function emits only 1 line of IR in debug, and seems to be fully optimized away in release.This bloat slows down builds (sllightly) and probably makes it less likely for some optimizations to occur (don't quote me on that, I'm not a compiler developer).
There are probably some other generated functions that suffer from this. I can investigate and open a PR if that's wanted.
from_nameis also fairly big13 + 7ndebug,12 + 14nrelease (not a typo, it's way bigger in release). I can get it down to13 + 6nand13 + 12nrelease by changing$PublicBitFlags::$Flag.bits()to$value(only affected debug), and changing the list of if statements to a match (only affected release).Thanks for investigating this @bolshoytoster! Would you be happy to open a PR with your improvements and we can take a look? We should be aiming for as small a footprint as possible.
I've opened a PR (#492)