summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/module-utils.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h
index 1ab365b81..f4c8c51c4 100644
--- a/src/ir/module-utils.h
+++ b/src/ir/module-utils.h
@@ -414,12 +414,21 @@ struct ParallelFunctionAnalysis {
using Func = std::function<void(Function*, T&)>;
ParallelFunctionAnalysis(Module& wasm, Func work) : wasm(wasm) {
- // Fill in map, as we operate on it in parallel (each function to its own
+ // Fill in the map as we operate on it in parallel (each function to its own
// entry).
for (auto& func : wasm.functions) {
map[func.get()];
}
+ doAnalysis(work);
+ }
+
+ // Perform an analysis by operating on each function, in parallel.
+ //
+ // This is called from the constructor (with the work function given there),
+ // and can also be called later as well if the user has additional operations
+ // to perform.
+ void doAnalysis(Func work) {
// Run on the imports first. TODO: parallelize this too
for (auto& func : wasm.functions) {
if (func->imported()) {