[PATCH] D62091: [CommandLine] Reduce size of Option class by moving more members into bit field
Don Hinton via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat May 18 11:58:29 PDT 2019
hintonda marked an inline comment as done.
hintonda added inline comments.
================
Comment at: llvm/include/llvm/Support/CommandLine.h:288
Categories; // The Categories this option belongs to
SmallPtrSet<SubCommand *, 4> Subs; // The subcommands this option belongs to.
----------------
beanz wrote:
> beanz wrote:
> > Side note: I wonder how many members actually get put into this. The common-case for most options is surely 0.
> From eyeballing (not an exhaustive search), I don't see anywhere that more than one Sub command is set. You might be able to save more space by shrinking the inline size here. If I read the code right, SmallPtrSet is 32 bytes + (sizeof (T) * N). In this case that should be 64 bytes. Changing the size to 2, would save another 16 bytes per option.
Actually, it's empty about 99% or the time and defaults to TopLevelSubCommand at that point. This is how all the options in passes are setup -- well over 1,000. Only a few tools currently use SubCommands -- the most I've seen is 4 by llvm-pdbutil.
So, I was considering something a bit more radical. Instead of each Option keeping track of SubCommand, and Category, membership, why not let the SubCommand's and Category's do it instead?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62091/new/
https://reviews.llvm.org/D62091
More information about the llvm-commits
mailing list