diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-11-07 10:41:05 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-07 10:41:05 -0800 |
commit | 30f0e0a6c9df43f3a70089629b6baa11688bfce4 (patch) | |
tree | c5ca79ea2ccd84df42efe19202b41aa6e6aa6213 /src/passes/DataFlowOpts.cpp | |
parent | b2070673bd4f6e4eb9eb7707bc0e64c76e9ecef7 (diff) | |
download | binaryen-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/passes/DataFlowOpts.cpp')
-rw-r--r-- | src/passes/DataFlowOpts.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/passes/DataFlowOpts.cpp b/src/passes/DataFlowOpts.cpp index 05e975049..e32fcb700 100644 --- a/src/passes/DataFlowOpts.cpp +++ b/src/passes/DataFlowOpts.cpp @@ -117,11 +117,11 @@ struct DataFlowOpts : public WalkerPass<PostWalker<DataFlowOpts>> { for (Index i = 0; i < node->values.size(); i++) { if (node->values[i]->isConst()) { auto* currp = getIndexPointer(expr, i); - if (!(*currp)->is<Const>()) { - // Directly represent it as a constant. - auto* c = node->values[i]->expr->dynCast<Const>(); - *currp = Builder(*getModule()).makeConst(c->value); - } + // Directly represent it as a constant. (Note that it may already be + // a constant, but for now to avoid corner cases just replace them + // all here.) + auto* c = node->values[i]->expr->dynCast<Const>(); + *currp = Builder(*getModule()).makeConst(c->value); } } // Now we know that all our DataFlow inputs are constant, and all |