diff options
author | Thomas Lively <tlively@google.com> | 2022-12-01 16:45:04 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-01 14:45:04 -0800 |
commit | f70bc4d6634c5a0b1aa88f3c073b783e83bb5712 (patch) | |
tree | e8e438dc036745cd4258b254d1b4d7fa06374b19 /src/passes/SignatureRefining.cpp | |
parent | 73b0487709370895cb8f9ac08cb2014143278fd6 (diff) | |
download | binaryen-f70bc4d6634c5a0b1aa88f3c073b783e83bb5712.tar.gz binaryen-f70bc4d6634c5a0b1aa88f3c073b783e83bb5712.tar.bz2 binaryen-f70bc4d6634c5a0b1aa88f3c073b783e83bb5712.zip |
Do not special case ref.null in `LUBFinder` (#5307)
Before we implemented bottom heap types, `ref.null` had to be annotated with
specific types. The `LUBFinder` utility ignored these types so that it could
find the best LUB from all considered non-null expressions, then go back and
update the type annotations on the nulls to match that LUB. Now that we have
bottom types, however, none of that is necessary, and in fact ignoring nulls can
miss possible refinements to bottom types.
Update and simplify `LUBFinder` so that it is a simple wrapper around the
underlying `Type::getLeastUpperBound` utility with no additional logic. Update
tests to account for the more powerful optimizations.
Diffstat (limited to 'src/passes/SignatureRefining.cpp')
-rw-r--r-- | src/passes/SignatureRefining.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/passes/SignatureRefining.cpp b/src/passes/SignatureRefining.cpp index 132079b76..15b89b2a7 100644 --- a/src/passes/SignatureRefining.cpp +++ b/src/passes/SignatureRefining.cpp @@ -161,7 +161,7 @@ struct SignatureRefining : public Pass { auto updateLUBs = [&](const ExpressionList& operands) { for (Index i = 0; i < numParams; i++) { - paramLUBs[i].noteUpdatableExpression(operands[i]); + paramLUBs[i].note(operands[i]->type); } }; @@ -178,7 +178,7 @@ struct SignatureRefining : public Pass { if (!lub.noted()) { break; } - newParamsTypes.push_back(lub.getBestPossible()); + newParamsTypes.push_back(lub.getLUB()); } Type newParams; if (newParamsTypes.size() < numParams) { @@ -197,7 +197,7 @@ struct SignatureRefining : public Pass { // value, or it can return a value but traps instead etc.). newResults = func->getResults(); } else { - newResults = resultsLUB.getBestPossible(); + newResults = resultsLUB.getLUB(); } if (newParams == func->getParams() && newResults == func->getResults()) { @@ -207,14 +207,7 @@ struct SignatureRefining : public Pass { // We found an improvement! newSignatures[type] = Signature(newParams, newResults); - // Update nulls as necessary, now that we are changing things. - if (newParams != func->getParams()) { - for (auto& lub : paramLUBs) { - lub.updateNulls(); - } - } if (newResults != func->getResults()) { - resultsLUB.updateNulls(); refinedResults = true; // Update the types of calls using the signature. |