summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ir/module-utils.cpp4
-rw-r--r--src/ir/module-utils.h12
-rw-r--r--src/passes/SignatureRefining.cpp4
3 files changed, 13 insertions, 7 deletions
diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp
index a061782f9..7861bde54 100644
--- a/src/ir/module-utils.cpp
+++ b/src/ir/module-utils.cpp
@@ -115,8 +115,8 @@ Counts getHeapTypeCounts(Module& wasm) {
}
// Collect info from functions in parallel.
- ModuleUtils::ParallelFunctionAnalysis<Counts, InsertOrderedMap> analysis(
- wasm, [&](Function* func, Counts& counts) {
+ ModuleUtils::ParallelFunctionAnalysis<Counts, Immutable, InsertOrderedMap>
+ analysis(wasm, [&](Function* func, Counts& counts) {
counts.note(func->type);
for (auto type : func->vars) {
counts.note(type);
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h
index 845acda00..5030bf84f 100644
--- a/src/ir/module-utils.h
+++ b/src/ir/module-utils.h
@@ -303,10 +303,14 @@ template<typename T> inline void iterImports(Module& wasm, T visitor) {
// Helper class for performing an operation on all the functions in the module,
// in parallel, with an Info object for each one that can contain results of
// some computation that the operation performs.
-// The operation performend should not modify the wasm module in any way.
-// TODO: enforce this
+// The operation performed should not modify the wasm module in any way, by
+// default - otherwise, set the Mutability to Mutable. (This is not enforced at
+// compile time - TODO find a way - but at runtime in pass-debug mode it is
+// checked.)
template<typename K, typename V> using DefaultMap = std::map<K, V>;
-template<typename T, template<typename, typename> class MapT = DefaultMap>
+template<typename T,
+ Mutability Mut = Immutable,
+ template<typename, typename> class MapT = DefaultMap>
struct ParallelFunctionAnalysis {
Module& wasm;
@@ -331,7 +335,7 @@ struct ParallelFunctionAnalysis {
struct Mapper : public WalkerPass<PostWalker<Mapper>> {
bool isFunctionParallel() override { return true; }
- bool modifiesBinaryenIR() override { return false; }
+ bool modifiesBinaryenIR() override { return Mut; }
Mapper(Module& module, Map& map, Func work)
: module(module), map(map), work(work) {}
diff --git a/src/passes/SignatureRefining.cpp b/src/passes/SignatureRefining.cpp
index d094382c7..2c2146c3f 100644
--- a/src/passes/SignatureRefining.cpp
+++ b/src/passes/SignatureRefining.cpp
@@ -76,7 +76,9 @@ struct SignatureRefining : public Pass {
bool canModify = true;
};
- ModuleUtils::ParallelFunctionAnalysis<Info> analysis(
+ // This analysis also modifies the wasm as it goes, as the getResultsLUB()
+ // operation has side effects (see comment on header declaration).
+ ModuleUtils::ParallelFunctionAnalysis<Info, Mutable> analysis(
*module, [&](Function* func, Info& info) {
if (func->imported()) {
return;