[LLVMdev] Disjoint types after reading several modules
baldrick at free.fr
Thu Feb 2 07:00:52 PST 2012
On 02/02/12 15:35, Clemens Hammacher wrote:
> On 2/2/12 2:32 PM, Duncan Sands wrote:
>> On 02/02/12 14:25, Clemens Hammacher wrote:
>>> On 2/2/12 1:51 PM, Duncan Sands wrote:
>>>> what do you mean by "copied over to the main module"? If you want to add
>>>> additional IR to the main module then you should link it in using the
>>> I think that the linker would indeed be able to remap the types
>>> correctly, but
>>> the main obstacle here is that we only copy individual functions.
>>> Maybe it would
>>> be possible to first copy the function into a new module, and then
>>> link this
>>> into the main module, but then again the question is how to correctly
>>> copy the
>>> function to the temporary module ;)
> Ah, thanks, I didn't know that tool.
> But I don't think it's applicable here. It's a command-line tool
all the LLVM command line tools are wrappers for functionality in the LLVM
libraries. If you look at the code for llvm-extract you will see that it is
about 150 lines long or so, and pretty straightforward. I'm suggesting you do
something like what that tool does to extract your function into a new module
in some appropriate way given your particular setup (that code would probably
be pretty close to what you are doing right now), then use the linker library
to link the new module into the target one. I'm not saying that this is the
only possibility, but it leaped to mind when I read your email, which seemed
to me to say "I'm trying to link a function into a module without using the
linker but it doesn't work well because we don't do XYZ that the linker does".
> all global values and functions which were not explicitely stated on the command
> line, and then dumps the remaining module.
> Are you proposing to
> - compute the set of referenced global values and functions from the individual
> - write the working module to the disk
> - run llvm-extract
> - read the extracted module
> - use the linker to link it into the main module?
> Then I think it's easier to use our current implementation, and just fix the
> issue with the duplicated types.
> Sorry if I misunderstood your suggestion.
More information about the llvm-dev