From 5d31ad2dafed4354ef4da5f798dba0b0eacad92d Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Wed, 5 Dec 2018 11:25:20 +0100 Subject: [PATCH 1/2] Test for unhandled default values in expression simplifier --- .../expressionSimplifier/unassigned_vars.yul | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul new file mode 100644 index 000000000..87391b8c8 --- /dev/null +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/unassigned_vars.yul @@ -0,0 +1,14 @@ +// c & d can't be optimized as expression simplifier doesn't handle default +// values yet +{ + let c + let d + let y := add(d, add(c, 7)) +} +// ---- +// expressionSimplifier +// { +// let c +// let d +// let y := add(add(d, c), 7) +// } From 54846ed0a708d57d25ac5eadd618f8137867df66 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Wed, 5 Dec 2018 11:24:55 +0100 Subject: [PATCH 2/2] Fix expression simplifier asserting on default values --- libyul/optimiser/SimplificationRules.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libyul/optimiser/SimplificationRules.cpp b/libyul/optimiser/SimplificationRules.cpp index b3190fefb..8ed63fa8d 100644 --- a/libyul/optimiser/SimplificationRules.cpp +++ b/libyul/optimiser/SimplificationRules.cpp @@ -114,7 +114,8 @@ bool Pattern::matches(Expression const& _expr, map { YulString varName = boost::get(_expr).name; if (_ssaValues.count(varName)) - expr = _ssaValues.at(varName); + if (Expression const* new_expr = _ssaValues.at(varName)) + expr = new_expr; } assertThrow(expr, OptimizerException, "");