diff options
author | Alon Zakai <azakai@google.com> | 2022-04-01 10:45:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-01 10:45:41 -0700 |
commit | e6a62de43ef66b1c1ad0d740e3deeeb6365ded1b (patch) | |
tree | 5e39e9f287a54721b07ced96e7fd4a08d0ae0cee /src | |
parent | 0102087b59a8ca5178437abc776c0499e16de8c7 (diff) | |
download | binaryen-e6a62de43ef66b1c1ad0d740e3deeeb6365ded1b.tar.gz binaryen-e6a62de43ef66b1c1ad0d740e3deeeb6365ded1b.tar.bz2 binaryen-e6a62de43ef66b1c1ad0d740e3deeeb6365ded1b.zip |
Use LiteralUtils::canMakeZero before calling makeZero (#4568)
Fixes #4562
Fixes #4564
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/CoalesceLocals.cpp | 9 | ||||
-rw-r--r-- | src/passes/Inlining.cpp | 6 | ||||
-rw-r--r-- | src/passes/RedundantSetElimination.cpp | 4 |
3 files changed, 10 insertions, 9 deletions
diff --git a/src/passes/CoalesceLocals.cpp b/src/passes/CoalesceLocals.cpp index 42296b5bf..f58e57e72 100644 --- a/src/passes/CoalesceLocals.cpp +++ b/src/passes/CoalesceLocals.cpp @@ -209,10 +209,11 @@ void CoalesceLocals::calculateInterferences() { for (Index i = func->getNumParams(); i < func->getNumLocals(); i++) { auto type = func->getLocalType(i); - if (type.isNonNullable()) { - // A non-nullable value cannot be used anyhow, but we must give it - // some value. A unique one seems least likely to result in surprise - // during debugging. + if (!LiteralUtils::canMakeZero(type)) { + // The default value for a type for which we can't make a zero cannot + // be used anyhow, but we must give it some value in this analysis. A + // unique one seems least likely to result in surprise during + // debugging. values[i] = valueNumbering.getUniqueValue(); } else { values[i] = valueNumbering.getValue(Literal::makeZeros(type)); diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp index e81649bd2..36610a224 100644 --- a/src/passes/Inlining.cpp +++ b/src/passes/Inlining.cpp @@ -343,9 +343,9 @@ doInlining(Module* module, Function* into, const InliningAction& action) { // zero-init value for (Index i = 0; i < from->vars.size(); i++) { auto type = from->vars[i]; - if (type.isNonNullable()) { - // Non-nullable locals do not need to be zeroed out. They have no zero - // value, and by definition should not be used before being written to, so + if (!LiteralUtils::canMakeZero(type)) { + // Non-zeroable locals do not need to be zeroed out. As they have no zero + // value they by definition should not be used before being written to, so // any value we set here would not be observed anyhow. continue; } diff --git a/src/passes/RedundantSetElimination.cpp b/src/passes/RedundantSetElimination.cpp index 56fca4bee..90925edf2 100644 --- a/src/passes/RedundantSetElimination.cpp +++ b/src/passes/RedundantSetElimination.cpp @@ -175,9 +175,9 @@ struct RedundantSetElimination std::cout << "new param value for " << i << '\n'; #endif start[i] = getUniqueValue(); - } else if (type.isNonNullable()) { + } else if (!LiteralUtils::canMakeZero(type)) { #ifdef RSE_DEBUG - std::cout << "new unique value for non-nullable " << i << '\n'; + std::cout << "new unique value for non-zeroable " << i << '\n'; #endif start[i] = getUniqueValue(); } else { |