Skip to content

Commit ad9a99c

Browse files
committed
[WIP][wasm-reduce] Inital type reducer
Sharing now in case it's useful, but not yet ready for review.
1 parent eebc710 commit ad9a99c

File tree

5 files changed

+474
-1
lines changed

5 files changed

+474
-1
lines changed

src/tools/wasm-reduce/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FILE(GLOB wasm_reduce_HEADERS *h)
22
set(wasm_reduce_SOURCES
33
destructive-reducer.cpp
44
reducer.cpp
5+
type-reducer.cpp
56
wasm-reduce.cpp
67
${wasm_reduce_HEADERS}
78
)

src/tools/wasm-reduce/destructive-reducer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ void DestructiveReducer::visitExpression(Expression* curr) {
217217
}
218218
}
219219
}
220+
} else if (curr->is<RefEq>()) {
221+
handleCondition(*getCurrentPointer());
220222
}
221223
// Finally, try to replace with a child.
222224
for (auto* child : ChildIterator(curr)) {

src/tools/wasm-reduce/reducer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "support/file.h"
2020
#include "support/path.h"
2121
#include "support/timing.h"
22+
#include "tools/wasm-reduce/type-reducer.h"
2223
#include "wasm-io.h"
2324

2425
namespace {
@@ -268,7 +269,9 @@ size_t Reducer::reduceDestructively(int factor) {
268269
// destroy!
269270
DestructiveReducer destructiveReducer(*this);
270271
destructiveReducer.walkModule(&wasm);
271-
return destructiveReducer.reduced;
272+
273+
TypeReducer typeReducer(*this);
274+
return destructiveReducer.reduced + typeReducer.reduce();
272275
}
273276

274277
bool Reducer::writeAndTestReduction() {

0 commit comments

Comments
 (0)