-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[tools][llc] Add --save-stats option
#163967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
|
|
||
| ; RUN: rm -f %t.stats && llc -mtriple=arm64-apple-macosx --save-stats=obj -o %t.s %s && test -f %t.stats | ||
| ; RUN: rm -f %{t:stem}.tmp.stats && llc -mtriple=arm64-apple-macosx --save-stats=cwd -o %t.s %s && test -f %{t:stem}.tmp.stats | ||
| ; RUN: rm -f %{t:stem}.tmp.stats && llc -mtriple=arm64-apple-macosx --save-stats -o %t.s %s && test -f %{t:stem}.tmp.stats | ||
| ; RUN: not llc -mtriple=arm64-apple-macosx --save-stats=invalid -o %t.s %s 2>&1 | FileCheck %s --check-prefix=INVALID_ARG | ||
|
|
||
| ; INVALID_ARG: {{.*}}llc{{.*}}: for the --save-stats option: Cannot find option named 'invalid'! | ||
| define i32 @func() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be some CHECK lines in here for at least a little bit of the structure of the stats file. |
||
| ret i32 0 | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |||||||
| #include "NewPMDriver.h" | ||||||||
| #include "llvm/ADT/STLExtras.h" | ||||||||
| #include "llvm/ADT/ScopeExit.h" | ||||||||
| #include "llvm/ADT/Statistic.h" | ||||||||
| #include "llvm/Analysis/TargetLibraryInfo.h" | ||||||||
| #include "llvm/CodeGen/CommandFlags.h" | ||||||||
| #include "llvm/CodeGen/LinkAllAsmWriterComponents.h" | ||||||||
|
|
@@ -45,6 +46,7 @@ | |||||||
| #include "llvm/Support/FormattedStream.h" | ||||||||
| #include "llvm/Support/InitLLVM.h" | ||||||||
| #include "llvm/Support/PGOOptions.h" | ||||||||
| #include "llvm/Support/Path.h" | ||||||||
| #include "llvm/Support/PluginLoader.h" | ||||||||
| #include "llvm/Support/SourceMgr.h" | ||||||||
| #include "llvm/Support/TargetSelect.h" | ||||||||
|
|
@@ -57,6 +59,7 @@ | |||||||
| #include "llvm/TargetParser/SubtargetFeature.h" | ||||||||
| #include "llvm/TargetParser/Triple.h" | ||||||||
| #include "llvm/Transforms/Utils/Cloning.h" | ||||||||
| #include <cassert> | ||||||||
| #include <memory> | ||||||||
| #include <optional> | ||||||||
| using namespace llvm; | ||||||||
|
|
@@ -203,6 +206,20 @@ static cl::opt<std::string> RemarksFormat( | |||||||
| cl::desc("The format used for serializing remarks (default: YAML)"), | ||||||||
| cl::value_desc("format"), cl::init("yaml")); | ||||||||
|
|
||||||||
| enum SaveStatsMode { None, Cwd, Obj }; | ||||||||
|
|
||||||||
| static cl::opt<SaveStatsMode> SaveStats( | ||||||||
| "save-stats", | ||||||||
| cl::desc("Save LLVM statistics to a file in the current directory" | ||||||||
| "(`-save-stats`/`-save-stats=cwd`) or the directory of the output" | ||||||||
| "file (`-save-stats=obj`). (default: cwd)"), | ||||||||
| cl::values(clEnumValN(SaveStatsMode::Cwd, "cwd", | ||||||||
| "Save to the current working directory"), | ||||||||
| clEnumValN(SaveStatsMode::Cwd, "", ""), | ||||||||
| clEnumValN(SaveStatsMode::Obj, "obj", | ||||||||
| "Save to the output file directory")), | ||||||||
| cl::init(SaveStatsMode::None), cl::ValueOptional); | ||||||||
|
|
||||||||
| static cl::opt<bool> EnableNewPassManager( | ||||||||
| "enable-new-pm", cl::desc("Enable the new pass manager"), cl::init(false)); | ||||||||
|
|
||||||||
|
|
@@ -276,7 +293,8 @@ static void setPGOOptions(TargetMachine &TM) { | |||||||
| TM.setPGOOption(PGOOpt); | ||||||||
| } | ||||||||
|
|
||||||||
| static int compileModule(char **, LLVMContext &); | ||||||||
| static int compileModule(char **argv, LLVMContext &Context, | ||||||||
| std::string &OutputFilename); | ||||||||
|
|
||||||||
| [[noreturn]] static void reportError(Twine Msg, StringRef Filename = "") { | ||||||||
| SmallString<256> Prefix; | ||||||||
|
|
@@ -355,6 +373,47 @@ static std::unique_ptr<ToolOutputFile> GetOutputStream(const char *TargetName, | |||||||
| return FDOut; | ||||||||
| } | ||||||||
|
|
||||||||
| static int MaybeEnableStats() { | ||||||||
| if (SaveStats == SaveStatsMode::None) { | ||||||||
| return 0; | ||||||||
| } | ||||||||
|
||||||||
| if (SaveStats == SaveStatsMode::None) | |
| return 0; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (SaveStats == SaveStatsMode::None) | |
| return 0; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assert(SaveStats == SaveStatsMode::Cwd && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.