aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/optimiser/SSAValueTracker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libyul/optimiser/SSAValueTracker.cpp')
-rw-r--r--libyul/optimiser/SSAValueTracker.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/libyul/optimiser/SSAValueTracker.cpp b/libyul/optimiser/SSAValueTracker.cpp
index a0e44b2b..23eb9ec2 100644
--- a/libyul/optimiser/SSAValueTracker.cpp
+++ b/libyul/optimiser/SSAValueTracker.cpp
@@ -33,12 +33,18 @@ void SSAValueTracker::operator()(Assignment const& _assignment)
m_values.erase(var.name);
}
+void SSAValueTracker::operator()(FunctionDefinition const& _funDef)
+{
+ for (auto const& var: _funDef.returnVariables)
+ setValue(var.name, nullptr);
+ ASTWalker::operator()(_funDef);
+}
+
void SSAValueTracker::operator()(VariableDeclaration const& _varDecl)
{
- static Expression const zero{Literal{{}, LiteralKind::Number, YulString{"0"}, {}}};
if (!_varDecl.value)
for (auto const& var: _varDecl.variables)
- setValue(var.name, &zero);
+ setValue(var.name, nullptr);
else if (_varDecl.variables.size() == 1)
setValue(_varDecl.variables.front().name, _varDecl.value.get());
}
@@ -50,5 +56,8 @@ void SSAValueTracker::setValue(YulString _name, Expression const* _value)
OptimizerException,
"Source needs to be disambiguated."
);
+ static Expression const zero{Literal{{}, LiteralKind::Number, YulString{"0"}, {}}};
+ if (!_value)
+ _value = &zero;
m_values[_name] = _value;
}