Linking Modules

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

One option is to make a named metadata node in the module with a list of everything you care about. After linking is done, zip down the list to see what got updated.

-Chris

Chris Lattner <clattner@apple.com> writes:

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

One option is to make a named metadata node in the module with a list
of everything you care about. After linking is done, zip down the
list to see what got updated.

Ah, that's an interesting approach! Thanks for the idea. :slight_smile:

                            -Dave