From f70bc4d6634c5a0b1aa88f3c073b783e83bb5712 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 1 Dec 2022 16:45:04 -0600 Subject: 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. --- src/passes/SignatureRefining.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/passes/SignatureRefining.cpp') 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. -- cgit v1.2.3