[llvm-dev] transfer type to 'local' context

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] transfer type to 'local' context

Matthias Braun via llvm-dev
Hi all,

is there an easy way to get a 'copy' of a type living in another context
into the local context?

Background:
when calling a function residing in a different module (context2) from a
module (context1), we first need to introduce a function declaration of
the function with empty body.

However, in order to do so, we need the function type.
pFuncInContext2->getType gives us the type in context2.
The returnType or argument type might refer to some types yet only
defined in context2 (e.g. special structs).

In order to get the functin declaration right, I would need to find out
if we have in context 1every necessary type referred to by the function
(in context2) and introduce it if not.

Is there an elegant way wrapping all this?
E.G. getTypeinLocalcontext(context1, pFuncTypeInContext2)?

Thx
Alex

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] transfer type to 'local' context

Matthias Braun via llvm-dev
On 8/15/2017 5:48 AM, alex via llvm-dev wrote:
> Hi all,
>
> is there an easy way to get a 'copy' of a type living in another context
> into the local context?

No, as far as I know.  (Probably not hard to write, if you really need
it, though; the LLVM type system is pretty simple.)

> Background:
> when calling a function residing in a different module (context2) from a
> module (context1), we first need to introduce a function declaration of
> the function with empty body.
>
> However, in order to do so, we need the function type.
> pFuncInContext2->getType gives us the type in context2.
> The returnType or argument type might refer to some types yet only
> defined in context2 (e.g. special structs).
>
> In order to get the functin declaration right, I would need to find out
> if we have in context 1every necessary type referred to by the function
> (in context2) and introduce it if not.
>
> Is there an elegant way wrapping all this?
> E.G. getTypeinLocalcontext(context1, pFuncTypeInContext2)?

Why are your modules in different contexts?  IR linking normally
involves loading all of the relevant modules into the same context.

-Eli

--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] transfer type to 'local' context

Matthias Braun via llvm-dev
Hi Eli,

indeed, there is no need to use separate contexts for different modules,
my mistake. That solved it for me. Thanks!

> On 8/15/2017 5:48 AM, alex via llvm-dev wrote:
>> Hi all,
>>
>> is there an easy way to get a 'copy' of a type living in another context
>> into the local context?
>
> No, as far as I know.  (Probably not hard to write, if you really need
> it, though; the LLVM type system is pretty simple.)
>
>> Background:
>> when calling a function residing in a different module (context2) from a
>> module (context1), we first need to introduce a function declaration of
>> the function with empty body.
>>
>> However, in order to do so, we need the function type.
>> pFuncInContext2->getType gives us the type in context2.
>> The returnType or argument type might refer to some types yet only
>> defined in context2 (e.g. special structs).
>>
>> In order to get the functin declaration right, I would need to find out
>> if we have in context 1every necessary type referred to by the function
>> (in context2) and introduce it if not.
>>
>> Is there an elegant way wrapping all this?
>> E.G. getTypeinLocalcontext(context1, pFuncTypeInContext2)?
>
> Why are your modules in different contexts?  IR linking normally
> involves loading all of the relevant modules into the same context.
>
> -Eli
>


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev