<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 30, 2015 at 11:08 AM, Rafael Espíndola <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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 30 November 2015 at 11:39, Teresa Johnson <<a href="mailto:tejohnson@google.com">tejohnson@google.com</a>> wrote:<br>
> tejohnson added inline comments.<br>
><br>
> ================<br>
> Comment at: lib/Linker/LinkModules.cpp:558<br>
> @@ +557,3 @@<br>
> +  void stripDeclsFromComdats();<br>
> +  void convertInvalidAliasesToDeclarations();<br>
> +<br>
> ----------------<br>
> rafael wrote:<br>
>> We cannot convert aliases to declarations.<br>
> Why? Note that after the conversion it isn't an alias, just a declaration to an externally defined symbol. This is needed to import anything that references an alias (especially now with your change in r254170).<br>
><br>
> I.e. if we import function foo() and it calls f() which is actually an alias to function f2(). If we don't import f2 (or with r254170 if f2() is not linkonce), then f() cannot be an alias in the destination (importing) module. So we convert the imported f() alias into a declaration. The linker will resolve this to the f() alias in the importing module eventually. It shouldn't be any different than having a module reference an alias defined elsewhere originally.<br>
<br>
</span>Why do we create the alias in the first place?<br>
<br>
If we don't want the alias to be imported, we should have not tried to clone it.<br>
If we want to import the alias but not the aliasee, we have to convert<br>
the aliasee to internal linkage. </blockquote><div><br></div><div>Do you mean if the imported function (say 'foo') references an alias ('f'), the aliasee 'f2' will have to be imported and converted to internal linkage? </div><div><br></div><div>David</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">That is something that is currently<br>
done only in the gold plugin. The existing llvm-link just gives the<br>
wrong result.<br>
<br>
All the logic behind doImportAsDefinition is something I hope to move<br>
out of the IR moving logic with the IRMover.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div></div>