summaryrefslogtreecommitdiff
path: root/src/dataflow
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-11-07 10:41:05 -0800
committerGitHub <noreply@github.com>2018-11-07 10:41:05 -0800
commit30f0e0a6c9df43f3a70089629b6baa11688bfce4 (patch)
treec5ca79ea2ccd84df42efe19202b41aa6e6aa6213 /src/dataflow
parentb2070673bd4f6e4eb9eb7707bc0e64c76e9ecef7 (diff)
downloadbinaryen-30f0e0a6c9df43f3a70089629b6baa11688bfce4.tar.gz
binaryen-30f0e0a6c9df43f3a70089629b6baa11688bfce4.tar.bz2
binaryen-30f0e0a6c9df43f3a70089629b6baa11688bfce4.zip
Fix a DataFlowOpts bug (#1729)
We create some fake nodes for internal use, and were looking at one by mistake. This fixes that by * Creating a non-ambiguous fake node, a call (which represents an unknown value properly, unlike a zero which we had before). * Make DFO not rely on those values, if it knows a node is constant, apply those constant values. Found by the fuzzer.
Diffstat (limited to 'src/dataflow')
-rw-r--r--src/dataflow/graph.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/dataflow/graph.h b/src/dataflow/graph.h
index f81b4f989..57c03bb2e 100644
--- a/src/dataflow/graph.h
+++ b/src/dataflow/graph.h
@@ -739,13 +739,15 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> {
// i1 zexts are a no-op for wasm
return makeUse(node->values[0]);
} else if (node->isVar()) {
- // Nothing valid for us to read here.
- // FIXME should we have a local index to get?
- return Builder(*module).makeConst(LiteralUtils::makeLiteralZero(node->wasmType));
+ // Nothing valid for us to read here. Emit a call, representing an unknown
+ // variable value.
+ return Builder(*module).makeCall(FAKE_CALL, {}, node->wasmType);
} else {
WASM_UNREACHABLE(); // TODO
}
}
+
+ const Name FAKE_CALL = "fake$dfo$call";
};
} // namespace DataFlow