[PATCH] D43199: [IRMover] Implement name based structure type mapping

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 16:07:39 PST 2018


Evgeny Leviant <eleviant at accesssoftek.com> writes:

> Actually I can't understand this:
>
>>  it should scan its types so that Foo is found to be isomorphic to Bar an not imported.
>
> imagine I have destination module A having this:
> struct Bar { ... };
> struct Foo { ... }; // isomorphic to Bar
>
> Now I'm importing this from module B:
> struct Foo { ... }; // same as in A
> struct Baz {
>    int i;
>    Foo F;
> };
>
> I need to associate type instance of 'Foo' in module B to some type instance in module A in order
> to copy `Foo F` from B to A.
> Let's assume that after scanning types in module A, I do now that Foo and Bar are isomorphic
> What should I do? (at the moment I'm checking names)

Another idea that might work is to merge Foo and Bar in the destination
module.

In the IRMover already walks all types in the constructor as you
noticed. NonOpaqueStructTypes is effectively a map from a type to the
canonical type. We could then do another walk (abstract the one the
TypeFinder does) and use mutateType to merge types in the destination
module.

This would simulate using an empty starting module, but with a much less
intrusive change.

I am happy to experiment with this, but first just add a
--initial-module option to llvm-link so that this test can just use
llvm-link.

Cheers,
Rafael


More information about the llvm-commits mailing list