<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 12, 2018 at 9:24 AM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>Teresa Johnson via Phabricator <<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>> writes:<br>
<br>
> tejohnson added a comment.<br>
><br>
> In <a href="https://reviews.llvm.org/D41988#974637" rel="noreferrer" target="_blank">https://reviews.llvm.org/D4198<wbr>8#974637</a>, @grimar wrote:<br>
><br>
>> In <a href="https://reviews.llvm.org/D41988#974604" rel="noreferrer" target="_blank">https://reviews.llvm.org/D4198<wbr>8#974604</a>, @tejohnson wrote:<br>
>><br>
>> > The same handling occurs for regular LTO (setting LinkerRedefined to WeakAny only when prevailing). Is this a problem there? If not, why?<br>
>><br>
>><br>
>> Yeah, I saw the same code in regular LTO,<br>
>>  but it is not a problem for it, our defsym.ll testcase mentioned has both ThinLTO and regular LTO sub-cases and that problem occurs only for ThinLTO case.<br>
>><br>
>> > Answering my own question perhaps, but I guess this is because in the ThinLTO case we end up importing bar2 and therefore promoting it to external linkage instead of leaving it alone which would cause it to be internalized?<br>
>><br>
>> That part I believe is exactly what I observed during debugging of ThinLTO.<br>
><br>
><br>
> Normally we would have a prevailing copy that would be imported, but I guess there is none here. Thinking more about the regular LTO case, since there also isn't a prevailing copy of bar2, is that non-prevailing copy kept in the merged module, and if so, wouldn't it be incorrectly inlined because it won't be set to WeakAnyLinkage?<br>
<br>
</span>It is not kept. In the regular LTO case a non prevailing symbol is<br></blockquote><div><br></div><div>Ok I see what happens. In addRegularLTO only prevailing symbols are added to the Keep set used when linking the IR (and a few other cases like linkonce_odr). In ThinLTO, obviously we don't have the IR during the thin link.</div><div><br></div><div>Here's what we currently do with the prevailing info for ThinLTO:</div><div>- in addThinLTO we already keep track of the prevailing module for a symbol (PrevailingModuleForGUID)</div><div>- this is only used right now in weak symbol resolution - for linkonce, we upgrade the prevailing symbol to weak, and for other WeakForLinker symbols we downgrade the non-prevailing to available_externally (when legal)</div><div><br></div><div>What we probably can/should do: Use PrevailingModuleForGUID to:</div><div>1) prevent importing of the non-prevailing copy when invoking ComputeCrossModuleImport</div><div>2) force the non-prevailing symbols to be internalized via thinLTOInternalizeAndPromoteInIndex</div><div><br></div><div>For #2, we can assert in isExported that anything in an ExportList (because it was imported) is the prevailing copy (after doing #1). Otherwise, if the symbol is not prevailing in that module then return false from isExported to ensure it is internalized.</div><div><br></div><div>Does that sound right?</div><div><br></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">
dropped.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_-8423072230877332220gmail_signature"><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)"> <a href="tel:(408)%20460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</div></div>