mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Restrict to only popping, but not reusing argument slots, as well as only freeing up until the return slots are allocated.
This commit is contained in:
parent
4b0f8383a6
commit
35c2eeab68
@ -159,7 +159,9 @@ void CodeTransform::freeUnusedVariables(bool _popUnusedSlotsAtStackTop)
|
|||||||
deleteVariable(*var);
|
deleteVariable(*var);
|
||||||
// Directly in a function body block, we can also delete the function arguments,
|
// Directly in a function body block, we can also delete the function arguments,
|
||||||
// which live in the virtual function scope.
|
// which live in the virtual function scope.
|
||||||
if (!m_scope->functionScope && m_scope->superScope && m_scope->superScope->functionScope)
|
// However, doing so after the return variables are already allocated, seems to have an adverse
|
||||||
|
// effect, so we only do it before that.
|
||||||
|
if (!returnVariablesAndFunctionExitAreSetup() && !m_scope->functionScope && m_scope->superScope && m_scope->superScope->functionScope)
|
||||||
for (auto const& identifier: m_scope->superScope->identifiers)
|
for (auto const& identifier: m_scope->superScope->identifiers)
|
||||||
if (Scope::Variable const* var = get_if<Scope::Variable>(&identifier.second))
|
if (Scope::Variable const* var = get_if<Scope::Variable>(&identifier.second))
|
||||||
if (m_variablesScheduledForDeletion.count(var))
|
if (m_variablesScheduledForDeletion.count(var))
|
||||||
@ -646,6 +648,9 @@ void CodeTransform::setupReturnVariablesAndFunctionExit()
|
|||||||
m_scope = m_scope->superScope;
|
m_scope = m_scope->superScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We could reuse unused slots for return variables, but it turns out this is detrimental in practice.
|
||||||
|
m_unusedStackSlots.clear();
|
||||||
|
|
||||||
if (m_delayedReturnVariables.empty())
|
if (m_delayedReturnVariables.empty())
|
||||||
{
|
{
|
||||||
m_functionExitStackHeight = 1;
|
m_functionExitStackHeight = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user