Skip to content

Commit

Permalink
Avoid pop unused function returns
Browse files Browse the repository at this point in the history
  • Loading branch information
r0qs committed Jul 9, 2024
1 parent 080673b commit cf8b262
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions libyul/YulControlFlowGraphExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ namespace
void validateStackSlot(StackSlot const& _slot)
{
std::visit(util::GenericVisitor{
[](FunctionCallReturnLabelSlot const&) { solAssert(false); },
[](FunctionReturnLabelSlot const&) { solAssert(false); },
[](FunctionCallReturnLabelSlot const&) { solAssert(false, "RET[] slot found"); },
[](FunctionReturnLabelSlot const&) { solAssert(false, "RET slot found"); },
[](VariableSlot const&) {},
[](LiteralSlot const&) {},
[](TemporarySlot const&) { solAssert(false); },
[](JunkSlot const&) { solAssert(false); },
[](TemporarySlot const&) { solAssert(false, "TMP slot found"); },
[](JunkSlot const&) { solAssert(false, "JUNK slot found"); },
}, _slot);
}
}
Expand Down
13 changes: 7 additions & 6 deletions libyul/optimiser/UnusedPruner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ void UnusedPruner::operator()(Block& _block)
subtractReferences(ReferencesCounter::countReferences(*varDecl.value));
statement = Block{std::move(varDecl.debugData), {}};
}
else if (varDecl.variables.size() == 1 && m_dialect.discardFunction(varDecl.variables.front().type))
statement = ExpressionStatement{varDecl.debugData, FunctionCall{
varDecl.debugData,
{varDecl.debugData, m_dialect.discardFunction(varDecl.variables.front().type)->name},
{*std::move(varDecl.value)}
}};
// TODO: hack to avoid creating TMP slots for unused variables in discard functions
///else if (varDecl.variables.size() == 1 && m_dialect.discardFunction(varDecl.variables.front().type))
/// statement = ExpressionStatement{varDecl.debugData, FunctionCall{
/// varDecl.debugData,
/// {varDecl.debugData, m_dialect.discardFunction(varDecl.variables.front().type)->name},
/// {*std::move(varDecl.value)}
/// }};
}
}
else if (std::holds_alternative<ExpressionStatement>(statement))
Expand Down

0 comments on commit cf8b262

Please sign in to comment.