Fix a bug in CSE where a variable that was already out of scope was used.

This commit is contained in:
chriseth
2018-10-18 14:55:51 +02:00
parent c34fa43d5b
commit 48749146da
5 changed files with 35 additions and 24 deletions
+2 -7
View File
@@ -38,16 +38,11 @@ void Rematerialiser::visit(Expression& _e)
if (m_value.count(identifier.name))
{
string name = identifier.name;
bool expressionValid = true;
for (auto const& ref: m_references[name])
if (!inScope(ref))
{
expressionValid = false;
break;
}
assertThrow(inScope(ref), OptimizerException, "");
assertThrow(m_value.at(name), OptimizerException, "");
auto const& value = *m_value.at(name);
if (expressionValid && CodeSize::codeSize(value) <= 7)
if (CodeSize::codeSize(value) <= 7)
_e = (ASTCopier{}).translate(value);
}
}