<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 30, 2015 at 11:29 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="">> Do you mean if the imported function (say 'foo') references an alias ('f'),<br>
> the aliasee 'f2' will have to be imported and converted to internal linkage?<br>
<br>
</span>Depends on what you want to import. My understanding is that your testcase is<br>
<br>
@f = alias void (), void ()* @f2<br>
define void @foo() {<br>
  call void @f()<br>
  ret void<br>
}<br>
define void @f2() {<br>
  ret void<br>
}<br>
<br>
if you want foo, f, f2, the output is like the input<br>
<br>
if you want just foo, you get<br>
<br>
define void @foo() {<br>
  call void @f()<br>
  ret void<br>
|<br>
declare void @f()<br>
<br></blockquote><div><br></div><div>This can not be done if f2 is in a comdat -- otherwise we may end up with unsat if f2 is deleted by the compiler in the other module.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
if you want just foo and f, you get<br>
<br>
@f = alias void(), void()* @f2<br>
define void @foo() {<br>
  call void @f()<br>
  ret void<br>
}<br>
define internal void @f2() {<br>
  ret void<br>
}<br>
<br></blockquote><div><br></div><div>This is not always safe to do -- in the case when f2's address is taken (and possibly used in address comparison). </div><div><br></div><div>So the solution depends on whether f/f2 is in comdat or not:</div><div><br></div><div>1) if f/f2 are not in comdat, </div><div>  1.1) import foo, f, f2 if we want foo and f2</div><div>  1.2) import foo and turn f into decl if we only want foo</div><div><br></div><div>2) if f/f2 are in comdat</div><div>  </div><div>   when importing foo, always import f and f2 regardless if we need f2 or not</div><div> </div><div><br></div><div>David</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
take a look at pr19848 for another example.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div></div>