Merge pull request #6959 from ethereum/fixUnusedPrunerForWasm

Fix unused pruner.
This commit is contained in:
chriseth 2019-06-18 18:06:26 +02:00 committed by GitHub
commit ee89a0353e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,7 @@
#include <libyul/optimiser/OptimizerUtilities.h>
#include <libyul/Exceptions.h>
#include <libyul/AsmData.h>
#include <libyul/Dialect.h>
#include <boost/algorithm/cxx11/none_of.hpp>
@ -92,12 +93,10 @@ void UnusedPruner::operator()(Block& _block)
subtractReferences(ReferencesCounter::countReferences(*varDecl.value));
statement = Block{std::move(varDecl.location), {}};
}
else if (varDecl.variables.size() == 1)
// In pure Yul, this should be replaced by a function call to `drop`
// instead of `pop`.
statement = ExpressionStatement{varDecl.location, FunctionalInstruction{
else if (varDecl.variables.size() == 1 && m_dialect.discardFunction())
statement = ExpressionStatement{varDecl.location, FunctionCall{
varDecl.location,
dev::eth::Instruction::POP,
{varDecl.location, m_dialect.discardFunction()->name},
{*std::move(varDecl.value)}
}};
}