[PATCH] D14623: [ThinLTO] Comdat importing fixes and related cleanup

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 30 13:13:21 PST 2015


On Mon, Nov 30, 2015 at 11:29 AM, Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

> > 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?
>
> Depends on what you want to import. My understanding is that your testcase
> is
>
> @f = alias void (), void ()* @f2
> define void @foo() {
>   call void @f()
>   ret void
> }
> define void @f2() {
>   ret void
> }
>
> if you want foo, f, f2, the output is like the input
>
> if you want just foo, you get
>
> define void @foo() {
>   call void @f()
>   ret void
> |
> declare void @f()
>
>
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.



> if you want just foo and f, you get
>
> @f = alias void(), void()* @f2
> define void @foo() {
>   call void @f()
>   ret void
> }
> define internal void @f2() {
>   ret void
> }
>
>
This is not always safe to do -- in the case when f2's address is taken
(and possibly used in address comparison).

So the solution depends on whether f/f2 is in comdat or not:

1) if f/f2 are not in comdat,
  1.1) import foo, f, f2 if we want foo and f2
  1.2) import foo and turn f into decl if we only want foo

2) if f/f2 are in comdat

   when importing foo, always import f and f2 regardless if we need f2 or
not


David


take a look at pr19848 for another example.
>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151130/7a17b385/attachment.html>


More information about the llvm-commits mailing list