diff options
author | sps-gold <79571312+sps-gold@users.noreply.github.com> | 2022-07-26 03:56:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-25 12:56:41 -0700 |
commit | 3a8d28f421a9452aff8f7ed2b140e12e2f314322 (patch) | |
tree | 8c67e20249568785d89796a24780c50640091463 /src/tools/wasm-split/split-options.cpp | |
parent | 68e2ed11e86e72cc4e12a1b4026ef19d5149fda9 (diff) | |
download | binaryen-3a8d28f421a9452aff8f7ed2b140e12e2f314322.tar.gz binaryen-3a8d28f421a9452aff8f7ed2b140e12e2f314322.tar.bz2 binaryen-3a8d28f421a9452aff8f7ed2b140e12e2f314322.zip |
[wasm-split] Add --print-profile option (#4771)
There are several reasons why a function may not be trained in deterministically.
So to perform quick validation we need to inspect profile.data (another ways requires split to be performed). However as profile.data is a binary file and is not self sufficient, so we cannot currently use it to perform such validation.
Therefore to allow quick check on whether a particular function has been trained in, we need to dump profile.data in a more readable format.
This PR, allows us to output, the list of functions to be kept (in main wasm) and those split functions (to be moved to deferred.wasm) in a readable format, to console.
Added a new option `--print-profile`
- input path to orig.wasm (its the original wasm file that will be used later during split)
- input path to profile.data that we need to output
optionally pass `--unescape`
to unescape the function names
Usage:
```
binaryen\build>bin\wasm-split.exe test\profile_data\MY.orig.wasm --print-profile=test\profile_data\profile.data > test\profile_data\out.log
```
note: meaning of prefixes
`+` => fn to be kept in main wasm
`-` => fn to be split and moved to deferred wasm
Diffstat (limited to 'src/tools/wasm-split/split-options.cpp')
-rw-r--r-- | src/tools/wasm-split/split-options.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/tools/wasm-split/split-options.cpp b/src/tools/wasm-split/split-options.cpp index b5929aad7..b8ccde83e 100644 --- a/src/tools/wasm-split/split-options.cpp +++ b/src/tools/wasm-split/split-options.cpp @@ -67,6 +67,9 @@ std::ostream& operator<<(std::ostream& o, WasmSplitOptions::Mode& mode) { case WasmSplitOptions::Mode::MergeProfiles: o << "merge-profiles"; break; + case WasmSplitOptions::Mode::PrintProfile: + o << "print-profile"; + break; } return o; } @@ -105,6 +108,16 @@ WasmSplitOptions::WasmSplitOptions() [&](Options* o, const std::string& argument) { mode = Mode::MergeProfiles; }) + .add("--print-profile", + "", + "Print profile contents in a human-readable format.", + WasmSplitOption, + {Mode::PrintProfile}, + Options::Arguments::One, + [&](Options* o, const std::string& argument) { + mode = Mode::PrintProfile; + profileFile = argument; + }) .add( "--profile", "", @@ -278,6 +291,12 @@ WasmSplitOptions::WasmSplitOptions() {Mode::Instrument, Mode::MergeProfiles}, Options::Arguments::One, [&](Options* o, const std::string& argument) { output = argument; }) + .add("--unescape", + "-u", + "Un-escape function names (in print-profile output)", + WasmSplitOption, + Options::Arguments::Zero, + [&](Options* o, const std::string& argument) { unescape = true; }) .add("--verbose", "-v", "Verbose output mode. Prints the functions that will be kept " @@ -362,6 +381,11 @@ bool WasmSplitOptions::validate() { case Mode::MergeProfiles: // Any number >= 1 allowed. break; + case Mode::PrintProfile: + if (inputFiles.size() != 1) { + fail("Must have exactly one profile path."); + } + break; } // Validate that all used options are allowed in the current mode. |