[LLVMdev] Several basic questions about Builder

Carter Cheng carter_cheng at yahoo.com
Mon Jun 29 01:10:25 PDT 2009


Thanks I managed to figure out most of basic points here based on these answers.

--- On Sun, 6/28/09, Eli Friedman <eli.friedman at gmail.com> wrote:

> From: Eli Friedman <eli.friedman at gmail.com>
> Subject: Re: [LLVMdev] Several basic questions about Builder
> To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu>
> Date: Sunday, June 28, 2009, 2:39 AM
> On Sun, Jun 28, 2009 at 1:05 AM,
> Carter Cheng<carter_cheng at yahoo.com>
> wrote:
> > 1) Using the Builder interface how does one create the
> equivalent of stack frames and access variables in the
> current stack frame or perhaps in the static enclosing scope
> (assuming functions can be nested)?
> 
> To create stack variables, you can use the alloca
> instruction; see
> http://llvm.org/docs/tutorial/LangImpl7.html#memory .
> 
> LLVM doesn't directly support nested functions; you'll have
> to lower
> them yourself.  For example, try something like the
> following in the
> LLVM demo page (http://llvm.org/demo/index.cgi) with
> optimization off:
> int main(int argc, char **argv) {
>   void a(int x) { if (x == 10) return; a(x+1); argc +=
> x; }
>   a(0);
>   return argc;
> }
> 
> > 2) Is it possible to deallocate functions from a
> module and recycle the memory used without restarting the
> JIT? I am trying to build a server type application where
> objects/classes maybe be deallocated and thus the associated
> functions will no longer be used.
> 
> That should be possible; I'm not sure of the details,
> though.
> 
> > 3) How does one sequence instructions using Builder
> similar to a semi-colon in a language like C?
> 
> Instructions are ordered within a basic block, and they are
> guaranteed
> to be executed in that order.  If you just build the
> instructions in
> the same order that the statements occur in the code, it
> should work
> without any special tweaking.
> 
> -Eli
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu 
>        http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 


      




More information about the llvm-dev mailing list