diff options
author | chriseth <chris@ethereum.org> | 2018-12-13 18:33:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-13 18:33:45 +0800 |
commit | 642c69f935c41d70f0dcfb0e89fcf3e626f7b38f (patch) | |
tree | 5b4cdf0d2e65cba050cf92d8de226e33ef73c2cd /libyul/optimiser/DataFlowAnalyzer.cpp | |
parent | 6e205cc4e32ccc55307a44ade4269448f6346924 (diff) | |
parent | 9557dd7e74a801ebafaf4777d60a591b0c484779 (diff) | |
download | dexon-solidity-642c69f935c41d70f0dcfb0e89fcf3e626f7b38f.tar dexon-solidity-642c69f935c41d70f0dcfb0e89fcf3e626f7b38f.tar.gz dexon-solidity-642c69f935c41d70f0dcfb0e89fcf3e626f7b38f.tar.bz2 dexon-solidity-642c69f935c41d70f0dcfb0e89fcf3e626f7b38f.tar.lz dexon-solidity-642c69f935c41d70f0dcfb0e89fcf3e626f7b38f.tar.xz dexon-solidity-642c69f935c41d70f0dcfb0e89fcf3e626f7b38f.tar.zst dexon-solidity-642c69f935c41d70f0dcfb0e89fcf3e626f7b38f.zip |
Merge pull request #5641 from ethereum/supportUnassigned
[Yul] 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.cpp | 9 |
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; } |