[LLVMdev] mapping types from a bitcode module
Michael Muller
mmuller at enduden.com
Tue Feb 28 04:45:40 PST 2012
Clemens Hammacher wrote:
> On 2/27/12 8:27 PM, Michael Muller wrote:
> >>> 3) destructively convert all of the types in the imported module to our
> >>> existing types.
> >>
> >> That's what we actually implemented, following the idea I described in
> >> the mentioned post. We don't identify identical struct types by their
> >> name, since even in the new type system, names don't actually mean
> >> anything. You could just strip them off.
> >> Instead, we use the pointer value of the types to identify them, since
> >> originally, all our modules reside in the same LLVMContext. Since that
> >> doesn't seem to be the case in your situation, you propably would have
> >> to use the name, or attach other metadata to uniquely identify your structs.
> >
> > I was actually fearful of this approach, it looked to me like the linker was
> > at least partially copying data structures to the destination module. I see
> > that there is a mutateType() method in Value, though it comes with a very
> > stern warning :-)
>
> Yeah, but as long as you mutate all types consistently, it works quite
> smoothly. The Verifier will tell you which values you missed ;)
>
> You shouldn't forget
> - function arguments
> - initializers of global variables
> - constants
>
> And of course you also have to consider composite types which contain a
> remapped struct.
Very cool - thanks, Clemens!
>
> Good luck! ;)
>
> Clemens
>
>
=============================================================================
michaelMuller = mmuller at enduden.com | http://www.mindhog.net/~mmuller
-----------------------------------------------------------------------------
Government is not reason, it is not eloquence; it is force. Like fire, it
is a dangerous servant and a fearsome master. - George Washington
=============================================================================
More information about the llvm-dev
mailing list