[llvm] [Support] Move the command-line Option constructor out of line (PR #202847)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 10 13:47:57 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: David Zbarsky (dzbarsky)
<details>
<summary>Changes</summary>
Move the shared `Option` base constructor from `CommandLine.h` to `CommandLine.cpp`. Typed `opt`, `list`, and `bits` constructors remain unchanged; option construction gains one direct non-virtual call and parsing behavior is unaffected.
A native AArch64 Release `opt` shrinks by 358,576 bytes, with `__text` down 229,796 bytes and dyld fixups unchanged.
Work towards #<!-- -->202616
AI tool disclosure: Co-authored with OpenAI Codex.
---
Full diff: https://github.com/llvm/llvm-project/pull/202847.diff
2 Files Affected:
- (modified) llvm/include/llvm/Support/CommandLine.h (+2-7)
- (modified) llvm/lib/Support/CommandLine.cpp (+7)
``````````diff
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h
index be754f3c159ca..efe87a23512fb 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -333,13 +333,8 @@ class LLVM_ABI Option {
void addSubCommand(SubCommand &S) { Subs.insert(&S); }
protected:
- explicit Option(enum NumOccurrencesFlag OccurrencesFlag,
- enum OptionHidden Hidden)
- : NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0),
- HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0),
- FullyInitialized(false), Position(0), AdditionalVals(0) {
- Categories.push_back(&getGeneralCategory());
- }
+ LLVM_ABI explicit Option(enum NumOccurrencesFlag OccurrencesFlag,
+ enum OptionHidden Hidden);
inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; }
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 82a7208429e00..ba321bab5a910 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -450,6 +450,13 @@ extrahelp::extrahelp(StringRef Help) : morehelp(Help) {
GlobalParser->MoreHelp.push_back(Help);
}
+Option::Option(NumOccurrencesFlag OccurrencesFlag, OptionHidden Hidden)
+ : NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0),
+ HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0),
+ FullyInitialized(false), Position(0), AdditionalVals(0) {
+ Categories.push_back(&getGeneralCategory());
+}
+
void Option::addArgument() {
GlobalParser->addOption(this);
FullyInitialized = true;
``````````
</details>
https://github.com/llvm/llvm-project/pull/202847
More information about the llvm-commits
mailing list