Open
Description
SSA doesn't track global state modification through indirect call. Consider the following two test cases, one performs the correct behavior but the other doesn't. I have attached screenshots of the resulting SSA IR in graph form
Correct:
pragma solidity >=0.4.16 <0.7.0;
contract Contract {
int public a;
function f() public {
e();
a += 1;
}
function e() public {
a -= 1;
}
}
Incorrect:
pragma solidity >=0.4.16 <0.7.0;
pragma solidity >=0.4.16 <0.7.0;
contract Contract {
int public a;
function f() public {
g();
a += 1;
}
function e() public {
a -= 1;
}
function g() public {
e();
}
}
The correct version uses a phi node to track the alteration to global state through the function call. However, when we add one more layer of indirection, it no longer tracks that alteration.