aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/optimiser/DataFlowAnalyzer.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-20 01:06:13 +0800
committerGitHub <noreply@github.com>2018-12-20 01:06:13 +0800
commit1df8f40cd2fd7b47698d847907b8ca7b47eb488d (patch)
tree5ed5816fe2d1a8a207e750d39884aca7957c8289 /libyul/optimiser/DataFlowAnalyzer.cpp
parentc8a2cb62832afb2dc09ccee6fd42c1516dfdb981 (diff)
parentddf54b21d1d002903624f61173ab4af197f50053 (diff)
downloaddexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar
dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.gz
dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.bz2
dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.lz
dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.xz
dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.tar.zst
dexon-solidity-1df8f40cd2fd7b47698d847907b8ca7b47eb488d.zip
Merge pull request #5697 from ethereum/develop
Merge develop into release for 0.5.2
Diffstat (limited to 'libyul/optimiser/DataFlowAnalyzer.cpp')
-rw-r--r--libyul/optimiser/DataFlowAnalyzer.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/libyul/optimiser/DataFlowAnalyzer.cpp b/libyul/optimiser/DataFlowAnalyzer.cpp
index 64c67b38..c8d236dc 100644
--- a/libyul/optimiser/DataFlowAnalyzer.cpp
+++ b/libyul/optimiser/DataFlowAnalyzer.cpp
@@ -96,7 +96,10 @@ void DataFlowAnalyzer::operator()(FunctionDefinition& _fun)
for (auto const& parameter: _fun.parameters)
m_variableScopes.back().variables.emplace(parameter.name);
for (auto const& var: _fun.returnVariables)
+ {
m_variableScopes.back().variables.emplace(var.name);
+ handleAssignment({var.name}, nullptr);
+ }
ASTModifier::operator()(_fun);
popScope();
@@ -136,17 +139,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;
}