Factored out part of https://reviews.llvm.org/D119880 as requested on the review.
Looks like a good refactoring, but needs a clang-format, and have added one question inline.
Was wondering if we could change SpecializationList to:
so that we move and transfer ownership instead of copying things here.
Will do, thanks.
Good remark, but will there really be a copy? I thought that the Return Value Optimization (copy elision) prevents that. Alternatively I could make the function void and pass the SpecializationList by reference on the argument list.
My understanding is that this is an optimisation that may or may not be implemented. Looks like to be specified for c++17 though, but since we are using C++14 being explicit might be better.
Changes from last revision:
- marked ArgInfo as const reference when passed to markArgInFuncSpecialization() and rewriteCallSites()
- passed SpecializationList by reference to calculateGains() instead of returning by value
- removed the IsPartial flag from isArgumentInteresting() and getPossibleConstants() as it's no longer used anywhere in the code
- clang-formatted the code