<div dir="ltr">On 27 October 2013 11:30, Stepan Dyatkovskiy <span dir="ltr"><<a href="mailto:stpworld@narod.ru" target="_blank">stpworld@narod.ru</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Nick.<br>
<br>
Can you help me sort some things out in MergeFucntions pass. While I was working on MergeFunctions pass I got several questions. I hardly tried to find all the answers by myself, but there are still two questions without answer.<br>
<br>
It is about merging functions itself (not comparing).<br>
<br>
First question is:<br>
Why sometimes we use RAUW and sometimes replaceDirectCallers. Would you help me with explanation how "overridability" and possibility to create aliases affects on our decision what to use RAUW or replaceDirectCallers?<br>
</blockquote><div><br></div><div>If we know that we're going to replace F with a thunk to G, and F is *not* weak, why should we ever knowingly call F? It would be faster to just go and call G directly. RAUW would also affect non-calling users who may end up comparing the addresses of functions.<br>
</div><div><br></div><div>(This whole thing predates unnamed_addr, but also, I was confused about GlobalAlias when writing it. I think I started in the belief that aliases had distinct addresses, then later learned they didn't?)</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">And the second question.<br>
There is a case when both "F" and "G" are overridable and target supports global aliases. We replace "G" with alias to "F". Its ok. But why we also replace "F" with alias to "F"? Suppose, for keeping callers equal when it is possible. Though aren't callers equal if caller "A" calls "F", and caller "B" calls "alias-to-F"? Perhaps there are more reasons?<br>
</blockquote><div><br></div><div><div>A function which is weak may be replaced during linking with another TU that has a strong definition. Suppose we know that the definitions are equivalent if neither one is overridden, but we need to allow for either one to be overridden without affecting the other?</div>
</div><div><br></div><div>Suppose functions F and G are equivalent and weak. What we do is create a third function H, and make it strong. Then we replace F and G with weak aliases (or thunks) to H. (To make this more efficient, the implementation actually repurposes F to be H and then deletes G and writes out two thunks/aliases. That's the "replace 'F' with alias to 'F'" you're seeing.)<br>
</div><div><br></div><div>Nick</div><div><br></div></div></div></div>