[opt] Add --save-stats option#167304
Merged
tomershafir merged 2 commits intollvm:mainfrom Nov 13, 2025
Merged
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
c97d8a2 to
6a888c7
Compare
This patch adds a Clang-compatible --save-stats option to opt, to provide an easy to use way to save LLVM statistics files when working with opt on the middle end. This is a follow up on the addition to `llc`: llvm#163967 Like on Clang, one can specify --save-stats, --save-stats=cwd, and --save-stats=obj with the same semantics and JSON format. The pre-existing --stats option is not affected. The implementation extracts the flag and its methods into the common `CodeGen/CommandFlags` as `LLVM_ABI`, using a new registration class to conservatively enable opt-in rather than let all tools take it. Its only needed for llc and opt for now. Then it refactors llc and adds support for opt.
6a888c7 to
af76571
Compare
dtcxzyw
reviewed
Nov 11, 2025
| cl::init(false)); | ||
| CGBINDOPT(DisableIntegratedAS); | ||
|
|
||
| #undef CGBINDOPT |
Member
There was a problem hiding this comment.
Should be moved after RegisterSaveStatsFlag
Contributor
Author
There was a problem hiding this comment.
I intentionally removed it because I dont think its needed anymore moving CGBINDOPT to a wider scope, becoming a redundant compile time overhead
jroelofs
approved these changes
Nov 11, 2025
tomershafir
added a commit
to swiftlang/llvm-project
that referenced
this pull request
Nov 25, 2025
This patch adds a Clang-compatible --save-stats option to opt, to provide an easy to use way to save LLVM statistics files when working with opt on the middle end. This is a follow up on the addition to `llc`: llvm#163967 Like on Clang, one can specify --save-stats, --save-stats=cwd, and --save-stats=obj with the same semantics and JSON format. The pre-existing --stats option is not affected. The implementation extracts the flag and its methods into the common `CodeGen/CommandFlags` as `LLVM_ABI`, using a new registration class to conservatively enable opt-in rather than let all tools take it. Its only needed for llc and opt for now. Then it refactors llc and adds support for opt. (cherry-pick 35ffe10)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch adds a Clang-compatible --save-stats option to opt, to provide an easy to use way to save LLVM statistics files when working with opt on the middle end.
This is a follow up on the addition to
llc: #163967Like on Clang, one can specify --save-stats, --save-stats=cwd, and --save-stats=obj with the same semantics and JSON format. The pre-existing --stats option is not affected.
The implementation extracts the flag and its methods into the common
CodeGen/CommandFlagsasLLVM_ABI, using a new registration class to conservatively enable opt-in rather than let all tools take it. Its only needed for llc and opt for now. Then it refactors llc and adds support for opt.