diff options
author | Alon Zakai <azakai@google.com> | 2022-03-25 07:34:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-25 07:34:05 -0700 |
commit | 05527357b307714dab259098e860e610f69ecf59 (patch) | |
tree | 07ef460494435a685debe1536bcbfc1d79789f24 /src/passes/param-utils.h | |
parent | 97d68ac572a0ffdc74fc5d8da2df65da42dc603e (diff) | |
download | binaryen-05527357b307714dab259098e860e610f69ecf59.tar.gz binaryen-05527357b307714dab259098e860e610f69ecf59.tar.bz2 binaryen-05527357b307714dab259098e860e610f69ecf59.zip |
[NFC] Move and generalize constant-parameter code from DeadArgumentElimination (#4547)
Similar to #4544, this moves the code to a utility function, and also
slightly generalizes it to support a list of functions (and not just 1)
and also a list of call_refs (and not just calls).
Diffstat (limited to 'src/passes/param-utils.h')
-rw-r--r-- | src/passes/param-utils.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/passes/param-utils.h b/src/passes/param-utils.h index 9bfbf1aec..10645b230 100644 --- a/src/passes/param-utils.h +++ b/src/passes/param-utils.h @@ -58,7 +58,7 @@ std::unordered_set<Index> getUsedParams(Function* func); // use cases are either to send a single function, or to send a set of functions // that all have the same heap type (and so if they all do not use some // parameter, it can be removed from them all). -bool removeParameter(const std::vector<Function*> funcs, +bool removeParameter(const std::vector<Function*>& funcs, Index index, const std::vector<Call*>& calls, const std::vector<CallRef*>& callRefs, @@ -67,13 +67,25 @@ bool removeParameter(const std::vector<Function*> funcs, // The same as removeParameter, but gets a sorted list of indexes. It tries to // remove them all, and returns which we removed. -SortedVector removeParameters(const std::vector<Function*> funcs, +SortedVector removeParameters(const std::vector<Function*>& funcs, SortedVector indexes, const std::vector<Call*>& calls, const std::vector<CallRef*>& callRefs, Module* module, PassRunner* runner); +// Given a set of functions and the calls and call_refs that reach them, find +// which parameters are passed the same constant value in all the calls. For +// each such parameter, apply it inside the function, that is, do a local.set of +// that value in the function. The parameter's incoming value is then ignored, +// which allows other optimizations to remove it. +// +// Returns the indexes that were optimized. +SortedVector applyConstantValues(const std::vector<Function*>& funcs, + const std::vector<Call*>& calls, + const std::vector<CallRef*>& callRefs, + Module* module); + } // namespace wasm::ParamUtils #endif // wasm_ir_function_h |