summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Hinton <hintonda@gmail.com>2019-05-18 20:46:35 +0000
committerDon Hinton <hintonda@gmail.com>2019-05-18 20:46:35 +0000
commit4b105f53082bba3a34d4b4585cdd4da13fc0be81 (patch)
tree4bad82826f70f3a4eebb0a87619c646c26c26a84
parent1a5d623ded8e0845d42c9ea272425a11391bf412 (diff)
downloadbcm5719-llvm-4b105f53082bba3a34d4b4585cdd4da13fc0be81.tar.gz
bcm5719-llvm-4b105f53082bba3a34d4b4585cdd4da13fc0be81.zip
[CommandLine] Reduce size of Option class
Summary: Reduce size of Option class from 184 bytes to 136 bytes by placing more member variables in Bit Field (16 bytes), and reducing the initial sizes of Categories and Subs to 1 (32 bytes). Saves about 48k for bin/opt. Reviewed By: beanz Tags: #llvm Differential Revision: https://reviews.llvm.org/D62091 llvm-svn: 361107
-rw-r--r--llvm/include/llvm/Support/CommandLine.h27
1 files changed, 14 insertions, 13 deletions
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h
index d144c9b0f0f..3cc2c3c0121 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -265,27 +265,27 @@ class Option {
// Out of line virtual function to provide home for the class.
virtual void anchor();
- int NumOccurrences = 0; // The number of times specified
+ uint16_t NumOccurrences; // The number of times specified
// Occurrences, HiddenFlag, and Formatting are all enum types but to avoid
// problems with signed enums in bitfields.
- unsigned Occurrences : 3; // enum NumOccurrencesFlag
+ uint16_t Occurrences : 3; // enum NumOccurrencesFlag
// not using the enum type for 'Value' because zero is an implementation
// detail representing the non-value
- unsigned Value : 2;
- unsigned HiddenFlag : 2; // enum OptionHidden
- unsigned Formatting : 2; // enum FormattingFlags
- unsigned Misc : 5;
- unsigned Position = 0; // Position of last occurrence of the option
- unsigned AdditionalVals = 0; // Greater than 0 for multi-valued option.
+ uint16_t Value : 2;
+ uint16_t HiddenFlag : 2; // enum OptionHidden
+ uint16_t Formatting : 2; // enum FormattingFlags
+ uint16_t Misc : 5;
+ uint16_t FullyInitialized : 1; // Has addArgument been called?
+ uint16_t Position; // Position of last occurrence of the option
+ uint16_t AdditionalVals; // Greater than 0 for multi-valued option.
public:
StringRef ArgStr; // The argument string itself (ex: "help", "o")
StringRef HelpStr; // The descriptive text message for -help
StringRef ValueStr; // String describing what the value of this option is
- SmallVector<OptionCategory *, 2>
+ SmallVector<OptionCategory *, 1>
Categories; // The Categories this option belongs to
- SmallPtrSet<SubCommand *, 4> Subs; // The subcommands this option belongs to.
- bool FullyInitialized = false; // Has addArgument been called?
+ SmallPtrSet<SubCommand *, 1> Subs; // The subcommands this option belongs to.
inline enum NumOccurrencesFlag getNumOccurrencesFlag() const {
return (enum NumOccurrencesFlag)Occurrences;
@@ -341,8 +341,9 @@ public:
protected:
explicit Option(enum NumOccurrencesFlag OccurrencesFlag,
enum OptionHidden Hidden)
- : Occurrences(OccurrencesFlag), Value(0), HiddenFlag(Hidden),
- Formatting(NormalFormatting), Misc(0) {
+ : NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0),
+ HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0),
+ FullyInitialized(false), Position(0), AdditionalVals(0) {
Categories.push_back(&GeneralCategory);
}
OpenPOWER on IntegriCloud