[llvm] [tools][llc] Add `--save-stats` option (PR #163967)
Jon Roelofs via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 27 16:03:00 PDT 2025
================
@@ -355,6 +366,50 @@ static std::unique_ptr<ToolOutputFile> GetOutputStream(const char *TargetName,
return FDOut;
}
+static int MaybeEnableStats() {
+ if (SaveStats.getNumOccurrences() > 0) {
+ if (SaveStats.empty() || SaveStats == "cwd" || SaveStats == "obj") {
+ llvm::EnableStatistics(false);
+ } else {
+ WithColor::error(errs(), "llc")
+ << "Invalid --save-stats value: " << SaveStats
+ << ", must be empty, 'cwd' or 'obj'\n";
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int MaybeSaveStats(std::string &&OutputFilename) {
+ if (SaveStats.getNumOccurrences() > 0) {
----------------
jroelofs wrote:
recommend inverting this, and turning it into an early return, so as to reduce the amount of indentation in the function.
https://github.com/llvm/llvm-project/pull/163967
More information about the llvm-commits
mailing list