[FuncSpec] Decouple cost/benefit analysis, allowing sorting of candidates.
This mostly is the same code that is refactored to decouple the cost and benefit analysis. The biggest change is top-level function specializeFunctions that now drives the transformation more like this: specializeFunctions() { Cost = getSpecializationCost(F); calculateGains(F, Cost); specializeFunction(F); } while this is just a restructuring, it helps the functional change in calculateGains. I.e., we now sort the candidates based on the expected specialisation gain, which we didn't do before. For this, a book keeping struct ArgInfo was introduced. If we have a list of N candidates, but we only want specialise less than N as set by option -func-specialization-max-constants, we sort the list and discard the candidates that give the least benefit. Given a formal argument, this change results in selecting the best actual argument(s). This is NFC'ish in that this shouldn't change the current output (hence no test change here), but in follow ups starting with D115509, it should and I want to go one step further and compare all functions and all arguments, which will mostly build on top of this refactoring and change. Differential Revision: https://reviews.llvm.org/D115458
Loading
Please sign in to comment