Merge pull request #7418 from ethereum/ssaReverseFix

Fix SSA reverser for declaration + self-assignment
This commit is contained in:
chriseth 2019-09-12 20:02:18 +02:00 committed by GitHub
commit 63a8cda1d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 12 deletions

View File

@ -56,6 +56,11 @@ void SSAReverser::operator()(Block& _block)
identifier && identifier &&
identifier->name == varDecl->variables.front().name identifier->name == varDecl->variables.front().name
) )
{
// in the special case a == a_1, just remove the assignment
if (assignment->variableNames.front().name == identifier->name)
return make_vector<Statement>(std::move(_stmt1));
else
return make_vector<Statement>( return make_vector<Statement>(
Assignment{ Assignment{
std::move(assignment->location), std::move(assignment->location),
@ -69,6 +74,7 @@ void SSAReverser::operator()(Block& _block)
} }
); );
} }
}
// Replaces // Replaces
// let a_1 := E // let a_1 := E
// let a := a_1 // let a := a_1

View File

@ -40,6 +40,13 @@ class AssignmentCounter;
* a := E * a := E
* let a_1 := a * let a_1 := a
* *
* In the special case
* let a := E
* a := a
*
* the redundant assignment "a := a" is removed.
*
*
* Secondly, the SSA transform will rewrite * Secondly, the SSA transform will rewrite
* *
* let a := E * let a := E

View File

@ -0,0 +1,8 @@
{
let a := calldataload(0)
a := a
}
// ====
// step: ssaReverser
// ----
// { let a := calldataload(0) }