Sorry for the late reply. Thanks everyone for looking into this!
> To Sjoerd Meijer:
>> This general direction is that we change the cost-model, import more functions as a result, so that we can do more transformations. The questions that need answering are: what is this going to cost in compile-times, and what is the performance benefit?
For the cost and beneift, I marked them in `https://reviews.llvm.org/D105966`. Simply, for compile-time, there is no significant change except 502.gcc_r increased 30%. For code-size, the average increasement is 6.7%. And the maximum is 19%. For the performance benefit, the ThinLTO for function specialization version gains all the benefit from FullLTO version. Obiviously, the number are not so satisfying and this is the reason I marked that patch as WIP. The things I want to say is:
- The increasement for compile-time and code-size mainly comes the newly imported functions been specialized. Instead of calculating and storing the extra heuristics.
- The main purpose of this mail is to make sure we are on the right direction. In other words, ThinLTO for function specialization is pursued.
> To Sjoerd Meijer:
>> To have a more efficient discussion on this, I think it is best if you prototype your proposal. This makes things more concrete and also allows to get some first costs and benefits of the approach to test the whole idea. Without this, it all just remains a bit abstract.
Yeah, I thought I made the proposal in D105524, D105966 and D107136. Since the codes for function specialization changes relatively fast. It may not be applied directly. I would try to rebase it recently.
Another way to measure it is to `git reset --hard d4840175c95f6edcba21baae411589468`.
> To Sjoerd Meijer:
>> Regarding https://reviews.llvm.org/D105524, yes it is NFC and harmless, but it is not important. I.e., it is trivial and I'm sure we can get it approved in no-time
The problem is that function specialization gets changed fast. So that this patch couldn't be approved directly. It may be an extra cost. If we decide the ThinLTO for function specialization is a long-term direction, we should check it in first to avoid extra cost.
> To Teresa Johnson:
>> One important thing to note is that we import functions with available_externally linkage, because they still live in their original translation unit. The intention is to make them available for inlining, and then they get dropped. But specialization presumably mainly benefits the out of line copy, I think? So I'm not sure that the approach of allowing the specialization candidates to get imported will ultimately do what you want.
For imported functions with available_externally linkage, the strategy now is that if we decide to specialize it, we would copy the importanted function and change the linkage for cloned to local so that it wouldn't affect other translation unit. It looks fine to me. Correct me if there is any problems. Since linking is really magic.