summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-05-18 10:47:23 -0700
committerGitHub <noreply@github.com>2017-05-18 10:47:23 -0700
commit9c6b8e0f626ade30cee113294019edbdbf29dd36 (patch)
treeda088ba8eef1d3d20f1f0e9fa3b5af2c8dbeba1d /src/passes/Print.cpp
parentbb1c44a3f975bf8fb72216b9c04bcd34e31bd815 (diff)
downloadbinaryen-9c6b8e0f626ade30cee113294019edbdbf29dd36.tar.gz
binaryen-9c6b8e0f626ade30cee113294019edbdbf29dd36.tar.bz2
binaryen-9c6b8e0f626ade30cee113294019edbdbf29dd36.zip
Validate finalization (#1014)
* validate that types are properly finalized, when in pass-debug mode (BINARYEN_PASS_DEBUG env var): check after each pass is run that the type of each node is equal to the proper type (when finalizing it, i.e., fully recomputing the type). * fix many fuzz bugs found by that. * in particular, fix dce bugs with type changes not being fully updated during code removal. add a new TypeUpdater helper class that lets a pass update types efficiently, by the helper tracking deps between blocks and branches etc., and updating/propagating type changes only as necessary.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index 9a2edcb6b..a90cba7a7 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -25,6 +25,13 @@
namespace wasm {
+static int forceFull() {
+ if (getenv("BINARYEN_PRINT_FULL")) {
+ return std::stoi(getenv("BINARYEN_PRINT_FULL"));
+ }
+ return 0;
+}
+
struct PrintSExpression : public Visitor<PrintSExpression> {
std::ostream& o;
unsigned indent = 0;
@@ -41,9 +48,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
PrintSExpression(std::ostream& o) : o(o) {
setMinify(false);
- if (getenv("BINARYEN_PRINT_FULL")) {
- full = std::stoi(getenv("BINARYEN_PRINT_FULL"));
- }
+ if (!full) full = forceFull();
}
void visit(Expression* curr) {
@@ -802,7 +807,7 @@ std::ostream& WasmPrinter::printExpression(Expression* expression, std::ostream&
}
PrintSExpression print(o);
print.setMinify(minify);
- if (full) {
+ if (full || forceFull()) {
print.setFull(true);
o << "[" << printWasmType(expression->type) << "] ";
}