[LLVMdev] mapping types from a bitcode module

Clemens Hammacher hammacher at cs.uni-saarland.de
Tue Feb 28 01:41:31 PST 2012


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.

Good luck! ;)

Clemens

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6392 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120228/ae020ee5/attachment.bin>


More information about the llvm-dev mailing list