<div dir="ltr"><div dir="ltr">Sorry for the slow reply, I've been out of office. Some replies inline below. Teresa</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 11, 2021 at 9:00 PM chuanqi.xcq <<a href="mailto:yedeng.yd@linux.alibaba.com" target="_blank">yedeng.yd@linux.alibaba.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">Sorry for the late reply. T</span><span style="font-size:14px">hanks everyone for looking into this!</span></div><div style="clear:both"><span style="font-size:14px"><br></span></div><div style="clear:both">> To Sjoerd Meijer:</div><div style="clear:both"><span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">>> 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?</span></div><div style="clear:both"><span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></div><div style="clear:both"><span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">For the cost and beneift, I marked them in `<a href="https://reviews.llvm.org/D105966" target="_blank">https://reviews.llvm.org/D105966`</a>. 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. </span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">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:</span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">- The increasement for compile-time and code-size mainly comes the newly imported functions been specialized. Instead of calculating and storing the extra heuristics.</span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">- 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.</span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><br></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">> To Sjoerd Meijer:</span></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">>> <span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">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.</span></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">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.</span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Another way to measure it is to `git reset --hard d4840175c95f6edcba21baae411589468`.</span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">> To Sjoerd Meijer:</span></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">>> <span style="margin:0px;padding:0px;border:0px;outline:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;text-decoration:none;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:black"><span style="margin:0px;padding:0px;border:0px;outline:0px;background-color:rgb(255,255,255);display:inline;font-family:calibri,arial,helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)">Regarding </span><span style="margin:0px;padding:0px;border:0px;outline:0px;background-color:white;display:inline"><a href="https://reviews.llvm.org/D105524" style="margin:0px" target="_blank">https://reviews.llvm.org/D105524</a></span><span style="margin:0px;padding:0px;border:0px;outline:0px;background-color:rgb(255,255,255);display:inline;font-family:calibri,arial,helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)">, yes </span></span><span style="margin:0px;padding:0px;border:0px;outline:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;text-decoration:none;font-family:calibri,arial,helvetica,sans-serif;font-size:16px;color:rgb(0,0,0);background-color:rgb(255,255,255)">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</span></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><span style="margin:0px;padding:0px;border:0px;outline:0px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;text-decoration:none;font-family:calibri,arial,helvetica,sans-serif;font-size:16px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></span></span></div><div style="clear:both"><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:16px">The problem is that <span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">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.</span></span></div><div style="clear:both"><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:16px"><span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:16px"><span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">> To <span style="color:rgb(0,0,0);font-family:Calibri,sans-serif;font-size:15px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Teresa Johnson:</span></span></span></div><div style="clear:both"><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:16px"><span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">>> <span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">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.</span></span></span></div><div style="clear:both"><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:16px"><span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">For imported functions with </span><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">available_externally linkage, </span><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">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.</span></span></div></div></blockquote><div><br></div><div>Ah ok, I missed that aspect of the approach. Yes, making them internal copies should work, in that they will get kept and linking will work fine. However, this could definitely exacerbate the code size increases from specialization. Here is a possible case:</div><div><br></div><div>Assume a.cc:A() calls b.cc:B() (i.e. A and B are all in different TUs initially). Let's say B could be specialized when called via A. And further, assume A is small and hot, and is called from many many other TUs. Normally, we would be likely to import A aggressively since it is likely to be inlined (as it is small and hot). But if B is very large we may not want to normally import and inline it (and as such function specialization is very desirable). With this approach, B could be imported and specialized as a local copy many many times (wherever A is imported and inlined). It is possible that linker ICF could merge these copies, but that's not enabled by default and I'm not sure if it would always be able to do that. This could seem like an extreme example, but we have applications with 20K+ TUs internally.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="clear:both"><span style="color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"></span></div><div style="clear:both"><span style="color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">> To </span><span style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;font-family:Calibri,sans-serif;font-size:15px;float:none;display:inline">Teresa Johnson:</span></span></span></div><div style="clear:both"><span style="color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">>> <span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">It probably would be better to allow the necessary info to be propagated via the index back to the original TU so that it can be specialized in its original location.</span></span></span></div><div style="clear:both"><span style="color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></span></div><div style="clear:both"><span style="color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">It looks hard to do. I think the key point is that we make decision to specialize functions in the process of ThinLTO compiling, which is pararrel to other compilation unit. It looks like we need to do synchronization for ThinLTO, which sounds like to violate the design principles for ThinLTO.</span></span></span></div></div></blockquote><div><br></div><div>Actually, ThinLTO does utilize cross-module synchronization. The synchronization is implemented via the index provided to the ThinLTO backends in which whole program optimization decisions are recorded.</div><div><br></div><div>I could envision providing via the index a way to record the arg number and specialized value on the FunctionSummary for the function to be specialized, along with a globally unique suffix to append (decided during the thin link), for each specialization, and then on each caller FunctionSummary, which callsite should call a specialized version (indicated by the globally unique suffix to apply to the the called function name). I actually need to do something similar for context sensitive heap optimization (WIP), so presumably they could rely on a similar summary mechanism to coordinate the cross module renaming.</div><div><br></div><div>This approach will also require some additional info in the index for the callsite arguments that are constant (i.e. pass the constant instead of a marker that it is a constant) so we can make these decisions during the thin link.</div><div><br></div><div>It's definitely a bit more work, but probably something we'd want to do longer term, rather than creating many specialized local copies, so I'd just make sure that the work done for specialization via importing is extensible to this approach.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="clear:both"><span style="color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></span></div><div style="clear:both"><span style="color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">> <span style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;text-decoration:none;background-color:rgb(255,255,255);float:none;display:inline">To </span><span style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;text-decoration:none;background-color:rgb(255,255,255);font-family:Calibri,sans-serif;font-size:15px;float:none;display:inline">Teresa Johnson:</span></span></span></span></div><div style="clear:both"><span style="color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">> Agree with others that the solution should be prototyped so you can show some results in terms of not only the benefit, but also the cost. I.e. adding information about all of the function arguments will increase the size of the index - how significant is that increase? We want to ensure that the thin link portion of the ThinLTO build stays efficient as that is the only monolithic, serial portion of a ThinLTO build.</span></span></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><br></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">It's a great point to measure the size increased for index. I forget to measure it before. Then here are the numbers for SPEC2017 int. The method I used to measure the size for index is to compile the sizefor the `.o` objects compiled by `-flto=thin`. Correct me if the measurement is not precise.</span></div><div style="clear:both"></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">The results shows that for SPEC2017 intrate, the overall increased size is about  2.8%. More precisely,</span></div><div style="clear:both"></div><div style="clear:both"></div><div style="clear:both"><br></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">| benchamrk       | size change for all the .o files |<br>|-----------------|--------|<br>| 500.perlbench_r | +1.9%  |<br>| 502.gcc_r       | +3.8%  |<br>| 505.mcf_r       | +3%    |</span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">| 520.omnetpp_r | +12% |</span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">| 525.x264_r | +2.9% |</span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">| 531.deepsjeng_r | +1.4% |</span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">| 541.leela_r | +2% |</span></div></div></blockquote><div><br></div><div>The omnetpp increase is a little large, and it is more likely representative of large C++ applications. Do you know how much of this is due to the ArgUsage info vs the FuncSpecCostInfo? Not sure if there is a good way to shrink these though (I've only skimmed your patch).</div><div><br></div><div>Thanks,</div><div>Teresa</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><br></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">The size changes less than 1% are omitted.</span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><br></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"> </span><span style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;float:none;display:inline">To </span><span style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;font-family:Calibri,sans-serif;font-size:15px;float:none;display:inline">Teresa Johnson:</span></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">>> <span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">That being said, I think it is a great idea to try to extend function specialization to ThinLTO if it is giving good benefits with regular LTO.</span></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px"><br></span></div><div style="clear:both"><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px">Thanks for your approval for the direction very much!</span></div><div style="clear:both"><br></div><div style="clear:both">Thanks,</div><div style="clear:both">Chuanqi</div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><br></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><br></span></div><blockquote style="margin-right:0px;margin-top:0px;margin-bottom:0px"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">------------------------------------------------------------------</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">From:Sjoerd Meijer <<a href="mailto:Sjoerd.Meijer@arm.com" target="_blank">Sjoerd.Meijer@arm.com</a>></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">Send Time:2021年7月28日(星期三) 18:57</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">To:Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">Cc:llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>; Florian Hahn <<a href="mailto:florian_hahn@apple.com" target="_blank">florian_hahn@apple.com</a>>; chuanqi.xcq <<a href="mailto:yedeng.yd@linux.alibaba.com" target="_blank">yedeng.yd@linux.alibaba.com</a>></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">Subject:Re: [llvm-dev] [ThinLTO] Import functions to enable function specialization in ThinLTO</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><br></span></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)">
Many thanks for commenting on the ThinLTO part and the suggestions how to approach this!</div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)">
I also think that specialisation benefits the out of line copy. </div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)"><br></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)">
Cheers,<br>
Sjoerd.</div><div id="m_-7378504687413109506m_1863829777993672867m_2615377552018589730gmail-m_-3103333169288715551appendonsend"></div><hr style="display:inline-block;width:98%"><div id="m_-7378504687413109506m_1863829777993672867m_2615377552018589730gmail-m_-3103333169288715551divRplyFwdMsg"><span style="font-size:15px;color:rgb(0,0,0);font-family:Calibri,sans-serif"><b>From:</b> Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>><br><b>Sent:</b> 27 July 2021 16:00<br><b>To:</b> Sjoerd Meijer <<a href="mailto:Sjoerd.Meijer@arm.com" target="_blank">Sjoerd.Meijer@arm.com</a>><br><b>Cc:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>; Florian Hahn <<a href="mailto:florian_hahn@apple.com" target="_blank">florian_hahn@apple.com</a>>; chuanqi.xcq <<a href="mailto:yedeng.yd@linux.alibaba.com" target="_blank">yedeng.yd@linux.alibaba.com</a>><br><b>Subject:</b> Re: [llvm-dev] [ThinLTO] Import functions to enable function specialization in ThinLTO</span><div> </div></div><div><div>I can answer questions from the ThinLTO standpoint. Missed the earlier emails on this, but I just skimmed the other llvm-dev email and the patch. I have a high level question and can give some thoughts on the approach from a ThinLTO standpoint.
<div><br></div><div>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. It probably would be better to allow the necessary info to be propagated via the index
 back to the original TU so that it can be specialized in its original location.</div><div><br></div><div>Agree with others that the solution should be prototyped so you can show some results in terms of not only the benefit, but also the cost. I.e. adding information about all of the function arguments will increase the size of the index - how significant
 is that increase? We want to ensure that the thin link portion of the ThinLTO build stays efficient as that is the only monolithic, serial portion of a ThinLTO build. That being said, I think it is a great idea to try to extend function specialization to ThinLTO
 if it is giving good benefits with regular LTO.</div><div><br></div><div>Teresa</div></div><br><div><div>On Tue, Jul 27, 2021 at 5:56 AM Sjoerd Meijer via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)">
The motivation for this work was getting this working ThinLTO, which I know very little about that, so that's why I recommended getting buy in from ThinLTO folks for the general direction.</div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)"><br></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)">
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?</div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)"><br></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)">
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.</div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)"><br></div><div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)"><div style="margin:0px;font-size:15px;color:rgb(32,31,30);clear:both"><span style="margin:0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:black"><span style="margin:0px;background-color:rgb(255,255,255);display:inline;font-family:calibri,arial,helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)">Regarding
</span><span style="margin:0px;background-color:white;display:inline"><a href="https://reviews.llvm.org/D105524" style="margin:0px" target="_blank">https://reviews.llvm.org/D105524</a></span><span style="margin:0px;background-color:rgb(255,255,255);display:inline;font-family:calibri,arial,helvetica,sans-serif;font-size:16px;color:rgb(0,0,0)">,
 yes </span></span><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:16px;color:rgb(0,0,0);background-color:rgb(255,255,255)">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, but more important are the bigger questions that needs answers first. It's also better to avoid unnecessary churn if things turns out to be different.</span></div><div style="margin:0px;font-size:15px;color:rgb(32,31,30);clear:both"><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:16px;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br></span></div><div style="margin:0px;font-size:15px;color:rgb(32,31,30);clear:both"><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:16px;color:rgb(0,0,0);background-color:rgb(255,255,255)">My 2 cents.</span></div><div style="margin:0px;font-size:15px;color:rgb(32,31,30);clear:both"><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:16px;color:rgb(0,0,0);background-color:rgb(255,255,255)">Sjoerd.</span></div></div><div id="m_-7378504687413109506m_1863829777993672867m_2615377552018589730gmail-m_-3103333169288715551x_gmail-m_4179446858562089319appendonsend"></div><hr style="display:inline-block;width:98%"><div id="m_-7378504687413109506m_1863829777993672867m_2615377552018589730gmail-m_-3103333169288715551x_gmail-m_4179446858562089319divRplyFwdMsg"><span style="font-size:15px;color:rgb(0,0,0);font-family:Calibri,sans-serif"><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>>
 on behalf of chuanqi.xcq via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br><b>Sent:</b> 26 July 2021 07:30<br><b>To:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>; Florian Hahn <<a href="mailto:florian_hahn@apple.com" target="_blank">florian_hahn@apple.com</a>><br><b>Subject:</b> Re: [llvm-dev] [ThinLTO] Import functions to enable function specialization in ThinLTO</span><div> </div></div><div><div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">gentle ping~</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">------------------------------------------------------------------</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">From:llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">Send Time:2021年7月15日(星期四) 17:23</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">To:llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>; Florian Hahn <<a href="mailto:florian_hahn@apple.com" target="_blank">florian_hahn@apple.com</a>></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">Subject:Re: [llvm-dev] [ThinLTO] Import functions to enable function specialization in ThinLTO</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><br></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">Hi <span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Florian,</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Thanks
 for looking into this!</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">> I’d
 try to summarise the heuristics you propose to add, rather than focusing on the implementation details to start with.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both">Thanks. I agree with it. The direction are more important than details.</div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both">> <span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">You
 should also be able to collect and provide date on the effectiveness of those heuristics, like the number of additional functions imported, compared to the number of additionally specialised  functions.</span></div><div style="clear:both"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></div><div style="clear:both"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">If
 I understand right, you mean that I could collect these numbers after we summarised the heuristics we decide to use instead of collecting now.</span></div><div style="clear:both"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Collecting
 the numbers may not make sense to me. Since I think we should do statistics after we decided the direction.</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">> Also,
 the scope/focus on function specialisation seems a bit narrow for substantially increasing the number of imported functions.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">I
 think there are two apsects.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">-
 It depends on how much we could get from function specialization.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">-
 It depends the cost model to import more functions.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">For
 the first aspects, I think function specialization is potential because ipa-cp plays an important role in gcc.
</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">And
 the interprocedural value range propogation based on function specialization seems very potential to me.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">That's
 the reason that I want to look into function specialization.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">For
 the second aspects, I think we need more time to tuning it. Or in another words, we need to decide the heuristics first.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">I
 know it's hard to **decide**  heuristics without measuring. But the work process  I imaged maybe:</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">```</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Get
 a set of heuristics -> Tuning the cost model to decrease the overhead -> if succed, we got it -> else go back to the first step.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">```</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">> Do
 you think the proposed heuristics would also benefit other optimisations, like regular IPSCCP?</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Yes,
 I think regular IPSCCP could benefit from the proposed heuristics. Out of curiousty, I guess we could replace regular IPSCCP</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">once
 the function specialization pass is strong enough. What's your opinion?</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Finally,
 let me clarify the intention of this mail. I don't ask to get a solution right now. I know it is hard for every one.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">The
 intention is that if we could get a consensus that it is valuable that importing functions by heuristics for function specialization.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">If
 yes, we could continue the review process for <a href="https://reviews.llvm.org/D105524" target="_blank">https://reviews.llvm.org/D105524</a>, which extract the analysis part from function
</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">specialization
 pass. I believe this patch should be NFC and harmless.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Of
 course, it could much much better that we could discuss the heuristics and the cost model.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Let
 me introduce the heuristics and the cost model I proposed simply.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">The heuristics
 are:</span></span></div><div style="clear:both"><ul style="font-style:normal;font-variant-caps:normal;font-weight:normal;text-indent:0px;text-transform:none;text-decoration:none;margin:12px 0px 12px 30px;padding:0px;border:0px;list-style:disc;color:rgb(0,0,0);font-family:"Segoe UI","Segoe UI Emoji","Segoe UI Symbol",Lato,"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;text-align:left"><li style="margin:0px;padding:0px;border:0px;line-height:1.7em">Specialize Function Cost. An unsigned number, which is an estimation for the cost to clone one function.</li><li style="margin:0px;padding:0px;border:0px;line-height:1.7em">Base Bonus for specializing specific argument. A map from ArgNo to the corresponding base bonus. Here the base bonus means the bonus we could calculate by visiting the function body itself only
 (in other words, doesn't need to see the call site).</li><li style="margin:0px;padding:0px;border:0px;line-height:1.7em">ArgUsage. A map from ArgNo to the extra bonus for each call site. The extra bonus means the bonus we could calculate for specific call site. For example, if we passed a function in the call,
 we could calculate the possibility that the function could get inlined at the specific call site only.</li></ul><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">And the cost model are the same with function specialization pass right now and we could adjust it in the future.</span></div></div><div style="clear:both"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">The first one `<span style="color:rgb(0,0,0);font-family:"Segoe UI","Segoe UI Emoji","Segoe UI Symbol",Lato,"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:left;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Specialize
 Function Cost</span>` is the number of instruction in a function multiplies a factor.</span></div></div><div style="clear:both"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">The second one `Base Bonus` is calculated by how many possible loads for this argument and its alias now.
</span></div></div><div style="clear:both"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">I plan to add more situations for example:</span></div></div><div style="clear:both"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">```</span></div></div><div style="clear:both"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">int foo(bool cond) {</span></div></div><div style="clear:both"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">   if (cond) { // We could get more base bonus by the average instruction count in the branches.</span></div></div><div style="clear:both"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">   } else {</span></div></div><div style="clear:both"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">   }</span></div></div><div style="clear:both"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">}</span></div></div><div style="clear:both"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">```</span></div></div><div style="clear:both"><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">Or</span></div></div><div style="clear:both"><div style="clear:both"><div style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;clear:both"><div style="margin:0px;padding:0px;border:0px;outline:0px;clear:both"><span style="margin:0px;padding:0px;border:0px;outline:0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">```</span></div></div><div style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;clear:both"><div style="margin:0px;padding:0px;border:0px;outline:0px;clear:both"><span style="margin:0px;padding:0px;border:0px;outline:0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">int foo(int cond) {</span></div></div><div style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;clear:both"><div style="margin:0px;padding:0px;border:0px;outline:0px;clear:both"><span style="margin:0px;padding:0px;border:0px;outline:0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">   if (cond > 10) { // We could get the condition
 if cond is constant, so we could get more bonus.</span></div></div><div style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;clear:both"><div style="margin:0px;padding:0px;border:0px;outline:0px;clear:both"><span style="margin:0px;padding:0px;border:0px;outline:0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">   } else {</span></div></div><div style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;clear:both"><div style="margin:0px;padding:0px;border:0px;outline:0px;clear:both"><span style="margin:0px;padding:0px;border:0px;outline:0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">   }</span></div></div><div style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;clear:both"><div style="margin:0px;padding:0px;border:0px;outline:0px;clear:both"><span style="margin:0px;padding:0px;border:0px;outline:0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">}</span></div></div><div style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;clear:both"><div style="margin:0px;padding:0px;border:0px;outline:0px;clear:both"><span style="margin:0px;padding:0px;border:0px;outline:0px;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">```</span></div></div></div></div><div style="clear:both"><div style="clear:both"><div style="margin:0px;padding:0px;border:0px;outline:0px;color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;clear:both"><div style="margin:0px;padding:0px;border:0px;outline:0px;clear:both"></div></div><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">The third one `<span style="color:rgb(0,0,0);font-family:"Segoe UI","Segoe UI Emoji","Segoe UI Symbol",Lato,"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:left;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">ArgUsage</span>`,
 which describes the infomation in callsites and we could use it to calculate the extra bonus.</span></div></div><div style="clear:both"><div style="clear:both">Now it only contains the instruction count if the corresponding parameter is a function. Then we could get extra bonus</div></div><div style="clear:both"><div style="clear:both">from the potential inlining.</div></div><div style="clear:both"></div><div style="clear:both"><br></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Thanks,</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Chuanqi</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><span style="color:rgb(0,0,0);font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">------------------------------------------------------------------</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">From:Florian Hahn <<a href="mailto:florian_hahn@apple.com" target="_blank">florian_hahn@apple.com</a>></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">Send Time:2021年7月14日(星期三) 19:39</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">To:chuanqi.xcq <<a href="mailto:yedeng.yd@linux.alibaba.com" target="_blank">yedeng.yd@linux.alibaba.com</a>>; llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)">Subject:Re: [llvm-dev] [ThinLTO] Import functions to enable function specialization in ThinLTO</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;color:rgb(0,0,0)"><br></span></div><br><div><br><div>On 14 Jul 2021, at 09:38, chuanqi.xcq via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br><div><div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px">Hi all,</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px"><br></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px">Before I sent a mail to ask the opinion to how to import functions to enable function specialization in ThinLTO.</span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px">Maybe the question is too empty or the <span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">function
 specialization pass didn't get checked in at that time. So I didn't get responses.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Then
 now, the function specialization passes got checked in and I also made it a version in the downstream.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">So
 I tried to update my patches. The first patch is to extract the analysis part of function specialization as an analysis pass.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">(<a href="https://reviews.llvm.org/D105524" target="_blank">https://reviews.llvm.org/D105524</a>).</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">And
<span title="sjoerd.meijer@arm.com" style="border:none;margin:0px 2px 0px 0px;background-color:transparent;color:rgb(2,132,192)">
@sjoerd.meijer</span> suggests that it may be better that I ping this thread with more infomation to make us confident we are</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">in
 the right direction.</span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><br></span></span></div><div style="clear:both"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px"><span style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;text-align:start;text-indent:0px;text-transform:none;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">Then
 I updated this one: <a href="https://reviews.llvm.org/D105966" target="_blank">https://reviews.llvm.org/D105966</a>, which contains the detailed description and numbers.</span></span></div><div style="clear:both">Response in this thread or in that review page is fine to me either.</div><div style="clear:both"><br></div></div></div><br></div><div><br></div><div>I’d try to summarise the heuristics you propose to add, rather than focusing on the implementation details to start with. I think it might be helpful to motivate a set of heuristics first. You should also be able to collect and provide date on the effectiveness
 of those heuristics, like the number of additional functions imported, compared to the number of additionally specialised  functions.</div><div><br></div><div>Also, the scope/focus on function specialisation seems a bit narrow for substantially increasing the number of imported functions. Do you think the proposed heuristics would also benefit other optimisations, like regular IPSCCP?</div><div><br></div><div>Cheers,</div><div>Florian</div><br><div><br></div></div></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br></div><br clear="all"><div><br></div>
-- <br><div><div><div><span style="font-family:Times;font-size:medium"><table cellpadding="0" cellspacing="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"><br></td></tr></tbody></table></span></div></div></div></div></blockquote><div><br></div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top:2px solid rgb(213,15,37)">Teresa Johnson |</td><td nowrap style="border-top:2px solid rgb(51,105,232)"> Software Engineer |</td><td nowrap style="border-top:2px solid rgb(0,153,57)"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top:2px solid rgb(238,178,17)"><br></td></tr></tbody></table></span></div></div></div></div>