This patch adds function specialization to IPSCCP. After an initial IPSCCP data-flow is solved, we may find that a function argument can take on a particular constant value in some contexts. If this is the case, we can create a new version of the function in which the argument is replaced by the constant value and then recompute the data-flow. This allows constant propagation to cross function boundaries when an argument can take on more than one value.
Specialization is controlled by a goal-oriented heuristic that seeks to predict if replacing an argument with a particular constant value would result in any significant optimization opportunities. Currently, we limit this heuristic to exposing inlining opportunities via indirect call promotion, but the kinds of optimizations we look for can be extended in the future.
Specialization can be disabled by -ipsccp-enable-function-specialization=false.
Function cloning in constant propagation was mentioned on llvm-dev recently, so I thought I would throw this up for review. I've added a simple demonstration test, but we can add more tests to the patch if the approach looks good.
Long ago, there was a separate partial specialization pass. However, this pass was removed (in r123554 and r152759) apparently due to known bugs and lack of maintenance.
Please take a look.