From aed979604c84fc90330c0ca501ef6cc2a34e336b Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 29 May 2019 23:23:51 +0200 Subject: [PATCH] Fix unused pruner. --- libyul/optimiser/UnusedPruner.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libyul/optimiser/UnusedPruner.cpp b/libyul/optimiser/UnusedPruner.cpp index 00ccbc8e5..624f9d335 100644 --- a/libyul/optimiser/UnusedPruner.cpp +++ b/libyul/optimiser/UnusedPruner.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -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)} }}; }