[PATCH] D18986: [ThinLTO] Prevent importing of "llvm.used" values

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 18 17:00:43 PDT 2016


tejohnson added a comment.

In http://reviews.llvm.org/D18986#404590, @joker.eph wrote:

> In http://reviews.llvm.org/D18986#404584, @tejohnson wrote:
>
> > In http://reviews.llvm.org/D18986#404576, @joker.eph wrote:
> >
> > > > > If you import `bar()` it mean you are not considering my 1) but the 2) above (this is a function that *contains* inline asm and not a function that is *referenced* by inline asm).
> > >
> > > > 
> > >
> > > > 
> > >
> > > > I'm not following. When you said:
> > >
> > > > 
> > >
> > > > > 1. "llvm.used" symbols (that are referred *from* inline assembly)
> > >
> > > > 
> > >
> > > > 
> > >
> > > > I assumed you meant the variable like @myvar which is on the llvm.used, and is referenced in the inline asm:
> > >
> > > > 
> > >
> > > > > @llvm.used = appending global [1 x i8*] [i8* @myvar], section "llvm.metadata"
> > >
> > > > 
> > >
> > > > 
> > >
> > > > ...
> > >
> > > > 
> > >
> > > > >   call void asm sideeffect "movzbl     myvar(%rip), ...
> > >
> > > > 
> > >
> > > > 
> > >
> > > > (In the example there is no function referenced by inline asm, just a variable.)
> > >
> > > > 
> > >
> > > > It is the llvm.used symbol myvar which cannot be correctly handled with a private alias, unless I am missing something. Maybe you could show what you are proposing using this example (i.e. the example in the patch augmented with an import to the additional module containing bar() shown above).
> > >
> > >
> > > Let say `myvar` was instead `myfunc` and was referenced from the inline asm. And then let say you are trying to import `myfunc` into another module and you need to promote it. You should be able to rename `myfunc()` to `myfunc.1234()` and create a local alias `myfunc = alias myfunc.1234()`.
> > >  Makes sense?
> >
> >
> > I'm not sure local functions are fundamentally different. Note if we import a local function we don't really need to promote it (we can use the imported copy). But let's say a reference to local function myfunc is imported from module1.o,
>
>
> Yes this is what I was after.
>
> > it will need to be promoted/renamed. We could have a different local function myfunc that we import a reference to from module2.o, also requiring a promotion/rename. You can't create a single myfunc alias to both of them.
>
>
> I'm lost... The aliases lies in the *source* module and are internal. Let me examplify:
>
> ModuleA: defines `foo()`, which calls `barB()` and `barC()`
>  ModuleB: defines `barB()` which references `myLocalFunc()` (which is also in `llvm.used`)
>  ModuleC: defines `barC()` which references `myLocalFunc()` (which is also in `llvm.used`)
>
> Now to import `barB()` and `barC()` into ModuleA, you transform this way:
>
> ModuleA: defines `foo()`, import `barB()` and `barC()`, these are referencing `myLocalFunc.1234()` and `myLocalFunc.4567()` (promoted in each source module B and C)
>  ModuleB: defines `barB()` and `myLocalFunc.1234()` (promoted). And with barB() that references this promoted version. We also create an `internal alias myLocalFunc() = myLocalFunc.1234()` (the alias is also in `llvm.used`)
>  ModuleC: defines `barC()` and `myLocalFunc.4567()` (promoted). And with barC() that references this promoted version. We also create an `internal alias myLocalFunc() = myLocalFunc.4567()` (the alias is also in `llvm.used`)


Ah, now I understand our disconnect. What you describe above will work in ModuleB and ModuleC after promotion. The issue is in ModuleA, which now has references to myLocalFunc.1234 and myLocalFunc.4567, if those are referenced in inline assembly within the imported barB and barC. (Or using the example from this patch, the renamed myvar references in the imported inline assembly)


http://reviews.llvm.org/D18986





More information about the llvm-commits mailing list