mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #7418 from ethereum/ssaReverseFix
Fix SSA reverser for declaration + self-assignment
This commit is contained in:
commit
63a8cda1d4
@ -56,18 +56,24 @@ void SSAReverser::operator()(Block& _block)
|
||||
identifier &&
|
||||
identifier->name == varDecl->variables.front().name
|
||||
)
|
||||
return make_vector<Statement>(
|
||||
Assignment{
|
||||
std::move(assignment->location),
|
||||
assignment->variableNames,
|
||||
std::move(varDecl->value)
|
||||
},
|
||||
VariableDeclaration{
|
||||
std::move(varDecl->location),
|
||||
std::move(varDecl->variables),
|
||||
std::make_unique<Expression>(std::move(assignment->variableNames.front()))
|
||||
}
|
||||
);
|
||||
{
|
||||
// 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>(
|
||||
Assignment{
|
||||
std::move(assignment->location),
|
||||
assignment->variableNames,
|
||||
std::move(varDecl->value)
|
||||
},
|
||||
VariableDeclaration{
|
||||
std::move(varDecl->location),
|
||||
std::move(varDecl->variables),
|
||||
std::make_unique<Expression>(std::move(assignment->variableNames.front()))
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
// Replaces
|
||||
// let a_1 := E
|
||||
|
@ -40,6 +40,13 @@ class AssignmentCounter;
|
||||
* a := E
|
||||
* 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
|
||||
*
|
||||
* let a := E
|
||||
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
let a := calldataload(0)
|
||||
a := a
|
||||
}
|
||||
// ====
|
||||
// step: ssaReverser
|
||||
// ----
|
||||
// { let a := calldataload(0) }
|
Loading…
Reference in New Issue
Block a user