JIT and anonymous procs

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

JIT and anonymous procs

Jonathan S. Shapiro-2
The Kaleidoscope tutorial has us "interpreting" top-level expressions by
generating a one-shot anonymous procedure and executing that. Once the
expressions have been executed, these procedures will never be called
again.

How can the associated storage for this anonymous procedure be
reclaimed?


shap

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: JIT and anonymous procs

Chris Lattner
On Wed, 26 Mar 2008, Jonathan S. Shapiro wrote:
> The Kaleidoscope tutorial has us "interpreting" top-level expressions by
> generating a one-shot anonymous procedure and executing that. Once the
> expressions have been executed, these procedures will never be called
> again.
>
> How can the associated storage for this anonymous procedure be
> reclaimed?

All functions in the tutorial are referenced by their Function*.  The
Function* uniquely identifies a function and is independent of the name.

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: JIT and anonymous procs

Jonathan S. Shapiro-2
On Wed, 2008-03-26 at 10:40 -0700, Chris Lattner wrote:

> On Wed, 26 Mar 2008, Jonathan S. Shapiro wrote:
> > The Kaleidoscope tutorial has us "interpreting" top-level expressions by
> > generating a one-shot anonymous procedure and executing that. Once the
> > expressions have been executed, these procedures will never be called
> > again.
> >
> > How can the associated storage for this anonymous procedure be
> > reclaimed?
>
> All functions in the tutorial are referenced by their Function*.  The
> Function* uniquely identifies a function and is independent of the name.

I had understood that.

So now I have compiled and run my top level expression's anonymous
function. How do I go about properly freeing the Function object,
*including* removing the anonymous procedure name from any global symbol
table (if any) and also advising the runtime that the associated IR
module can now be dropped along with everything else that was generated?

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: JIT and anonymous procs

Sandro Magi-2
On Wed, Mar 26, 2008 at 2:01 PM, Jonathan S. Shapiro <[hidden email]> wrote:

>  > All functions in the tutorial are referenced by their Function*.  The
>  > Function* uniquely identifies a function and is independent of the name.
>
>  I had understood that.
>
>  So now I have compiled and run my top level expression's anonymous
>  function. How do I go about properly freeing the Function object,
>  *including* removing the anonymous procedure name from any global symbol
>  table (if any) and also advising the runtime that the associated IR
>  module can now be dropped along with everything else that was generated?

Freeing the machine code is straightforward:

http://llvm.org/doxygen/classllvm_1_1JIT.html#a8

Not sure about the Function instance itself. The delete operator would
be my first guess.

Sandro
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: JIT and anonymous procs

Sandro Magi-2
On Wed, Mar 26, 2008 at 3:55 PM, Sandro Magi <[hidden email]> wrote:
>  Freeing the machine code is straightforward:
>
>  http://llvm.org/doxygen/classllvm_1_1JIT.html#a8
>
>  Not sure about the Function instance itself. The delete operator would
>  be my first guess.

I believe that may be correct actually, as the Function destructor
invokes "dropAllReferences":

http://llvm.org/doxygen/classllvm_1_1Function.html#a55

Sandro
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: JIT and anonymous procs

Chris Lattner
In reply to this post by Jonathan S. Shapiro-2
On Wed, 26 Mar 2008, Jonathan S. Shapiro wrote:

>> All functions in the tutorial are referenced by their Function*.  The
>> Function* uniquely identifies a function and is independent of the name.
>
> I had understood that.
>
> So now I have compiled and run my top level expression's anonymous
> function. How do I go about properly freeing the Function object,
> *including* removing the anonymous procedure name from any global symbol
> table (if any) and also advising the runtime that the associated IR
> module can now be dropped along with everything else that was generated?

// Free JIT'd machine code:
EE->freeMachineCodeForFunction(F);

// Delete functions and IR:
F->eraseFromParent();

-Chris

--
http://nondot.org/sabre/
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev