From 9557dd7e74a801ebafaf4777d60a591b0c484779 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 12 Dec 2018 00:49:36 +0100 Subject: Support unassigned variables in the SSA value tracker and the data flow analyzer. --- libyul/optimiser/SSAValueTracker.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libyul/optimiser/SSAValueTracker.cpp') diff --git a/libyul/optimiser/SSAValueTracker.cpp b/libyul/optimiser/SSAValueTracker.cpp index ef96c379..a0e44b2b 100644 --- a/libyul/optimiser/SSAValueTracker.cpp +++ b/libyul/optimiser/SSAValueTracker.cpp @@ -35,11 +35,12 @@ void SSAValueTracker::operator()(Assignment const& _assignment) void SSAValueTracker::operator()(VariableDeclaration const& _varDecl) { - if (_varDecl.variables.size() == 1) - setValue(_varDecl.variables.front().name, _varDecl.value.get()); - else if (!_varDecl.value) + static Expression const zero{Literal{{}, LiteralKind::Number, YulString{"0"}, {}}}; + if (!_varDecl.value) for (auto const& var: _varDecl.variables) - setValue(var.name, nullptr); + setValue(var.name, &zero); + else if (_varDecl.variables.size() == 1) + setValue(_varDecl.variables.front().name, _varDecl.value.get()); } void SSAValueTracker::setValue(YulString _name, Expression const* _value) -- cgit