aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/optimiser/DataFlowAnalyzer.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-12 07:49:36 +0800
committerchriseth <chris@ethereum.org>2018-12-13 01:06:28 +0800
commit9557dd7e74a801ebafaf4777d60a591b0c484779 (patch)
treeb55af218e8debaeb4a79670f932e1e66afb736b6 /libyul/optimiser/DataFlowAnalyzer.cpp
parent5e0c312dad2daaae155486397bfbd26d6d172718 (diff)
downloaddexon-solidity-9557dd7e74a801ebafaf4777d60a591b0c484779.tar.gz
dexon-solidity-9557dd7e74a801ebafaf4777d60a591b0c484779.tar.zst
dexon-solidity-9557dd7e74a801ebafaf4777d60a591b0c484779.zip
Support unassigned variables in the SSA value tracker and the data flow analyzer.
Diffstat (limited to 'libyul/optimiser/DataFlowAnalyzer.cpp')
-rw-r--r--libyul/optimiser/DataFlowAnalyzer.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/libyul/optimiser/DataFlowAnalyzer.cpp b/libyul/optimiser/DataFlowAnalyzer.cpp
index 64c67b38..7bff2c89 100644
--- a/libyul/optimiser/DataFlowAnalyzer.cpp
+++ b/libyul/optimiser/DataFlowAnalyzer.cpp
@@ -136,17 +136,22 @@ void DataFlowAnalyzer::operator()(Block& _block)
void DataFlowAnalyzer::handleAssignment(set<YulString> const& _variables, Expression* _value)
{
+ static Expression const zero{Literal{{}, LiteralKind::Number, YulString{"0"}, {}}};
clearValues(_variables);
MovableChecker movableChecker;
if (_value)
movableChecker.visit(*_value);
- if (_variables.size() == 1)
+ else
+ for (auto const& var: _variables)
+ m_value[var] = &zero;
+
+ if (_value && _variables.size() == 1)
{
YulString name = *_variables.begin();
// Expression has to be movable and cannot contain a reference
// to the variable that will be assigned to.
- if (_value && movableChecker.movable() && !movableChecker.referencedVariables().count(name))
+ if (movableChecker.movable() && !movableChecker.referencedVariables().count(name))
m_value[name] = _value;
}