This adds support for specialising recursive functions. For example, consider this program:
int Global = 1;
void recursiveFunc(int *arg) {
if (*arg < 4) {
print(*arg);
recursiveFunc(*arg + 1);
}
}
void main() {
recursiveFunc(&Global);
}after 3 iterations of function specialisation, followed by inlining of the specialised versions of recursiveFunc, the main function looks like this:
void main() {
print(1);
print(2);
print(3);
}To support this, the following has been added:
- Update the solver and state of the new specialised functions,
- An optimisation to propagate constant stack values after each iteration of function specialisation, which is necessary for the next iteration to recognise the constant values and trigger.
mark this with static