[PATCH] D14623: [ThinLTO] Comdat importing fixes and related cleanup
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 1 07:13:03 PST 2015
On 30 November 2015 at 19:09, Teresa Johnson <tejohnson at google.com> wrote:
> On Mon, Nov 30, 2015 at 1:49 PM, Rafael EspĂndola
> <rafael.espindola at gmail.com> wrote:
>>> Right, which is why I have stripDeclsFromComdats() in this patch (see
>>> the header comments for that new routine). Forgot about that, so I
>>> think the issue with the change made in r254170 interacting badly with
>>> comdat groups is not an issue. So the main thing is that what we want
>>> here is for the alias to become a decl in the importing module, which
>>> happens during global value proto linking at head and as a post-pass
>>> after lazy linking in this patch.
>>
>>
>> What I don't get it is why copy it just to drop it in the end. Can't
>> we make the right decision when first looking at f2?
>
> Consider the following example:
>
> In the importing module:
>
> define i32 @main() #0 {
> entry:
> call void (...) @func1()
> call void (...) @func2()
> ret i32 0
> }
>
>
> In the import source module:
>
> @alias1 = alias void (...), bitcast (void ()* @comdatfunc to void (...)*)
> $comdatfunc = comdat any
> define linkonce_odr void @comdatfunc() comdat {
> entry:
> ret void
> }
>
>
> define void @func1() {
> entry:
> ret void
> }
>
> define void @func2() {
> call void @alias1()
> ret void
> }
>
>
> Now consider two importing cases:
> 1) We import func1
> 2) We import func2
>
> In case 1), we don't need to import the comdat group definitions,
> since none are referenced. When we link global value protos and see
> the alias,
Lets try to abstract this away from the current implementation. Having
a "link global value protos" stage is just the current, bad,
organization.
The steps needed in both cases are
1)
* Create a decl for func 1
* Move the body of func1. We are done.
2)
* Create a decl for func2
* Move the body func2
* Create an alias decl for alias1
* Recurse down the aliasee:
* create a decl for comdatfunc
* copy the body for comdatfunc
* Set the aliasee
At no point do we need to create a GlobalVariable that becomes a
GlobalAlias or the other way around.
Cheers,
Rafael
More information about the llvm-commits
mailing list