[LLVMdev] Linking Modules

David Greene dag at cray.com
Fri Feb 3 10:05:07 PST 2012


I've hacked around this problem in the past but I would like to
do things the "right" way.

Suppose I have this scenario:

- A data structure that maps LLVM Values off to the side.
- We link two Modules together

The data structure is a map from one IR to another, so when we see
objects in one IR we know which LLVM Values represent them.  Somehow the
data structure needs to be updated with the new Values created as a
result of the linking.

I was hoping a TrackingVH could do this but it's not enough.  For one
thing, RAUW is not called for everything during linking, specifically,
when copying from the source module.  To my surprise LLVM actually
creates whole new Values in some cases and just copies the bits from the
source Module Value to the new Value.  RAUW is never called, only the
linker's ValueMap is updated.

I used to hack this by sending down my own ValueMap and using the
resulting mapping to update the data structure.  But that requires
changing the interface to LinkModules and some of its guts.

How do I do this the "right" way?  Do I need a custome CallbackcVH or
does something already exist to do this?

Thanks!

                                -Dave



More information about the llvm-dev mailing list