Infinite loop fix to constant propagation optimisation
Summary
This merge request fixes an infinite loop that can occur in the CONSTPROP optimisation. This occurs in a piece of code that converts an Inc/Dec statement into Add/Sub to remove side-effects, but firstpass is forcibly run again and this converts it back to an Inc/Dec node, which is then converted into Add/Sub by CONSTPROP, ad infinitum. This tends to only occur if USELOADMODIFYSTORE is disabled.
This patch prevents this by making the Add/Sub node 'internal', and then looking out for that flag when CONSTPROP is run again (since the flag is preserved when firstpass transforms it back) = if the 'internal' flag is present, the Inc/Dec node isn't transformed into Add/Sub, since it's already been done once before, and hence CONSTPROP is not caught in an infinite loop and can move on.
System
Platform-agnostic, but developed and tested on x86_64-win64.
What is the current bug behavior?
When building the compiler with make clean all OPT="-O3 -OoNOUSELOADMODIFYSTORE"
, the compiler gets caught in an infinite loop while building the System unit with ppc1
.
What is the behavior after applying this patch?
The compiler should build successfully with these flags.
Relevant logs and/or screenshots
No logs to post since it just hangs until the process is forcibly terminated.