variable size alloca

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

variable size alloca

Ryan M. Lefever
To what do variable size LLVM alloca instructions get translated, when
they are turned into machine code?  I compiled a piece of code to
bitcode and disassembled it.  The disassembled code showed that there
were alloca instructions with variable-sized parameters within the
bitcode.  When I turned the bitcode into machine code, I performed an nm
on the result but didn't see any symbols referring to alloca.  So, I'm
guessing that they don't get translated to an alloca system call.  If
that's the case, to what do they get translated?

Regards,
Ryan

_______________________________________________
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: variable size alloca

John Criswell-2
Ryan M. Lefever wrote:
> To what do variable size LLVM alloca instructions get translated, when
> they are turned into machine code?  I compiled a piece of code to
> bitcode and disassembled it.  The disassembled code showed that there
> were alloca instructions with variable-sized parameters within the
> bitcode.  When I turned the bitcode into machine code, I performed an nm
> on the result but didn't see any symbols referring to alloca.  So, I'm
> guessing that they don't get translated to an alloca system call.  If
> that's the case, to what do they get translated?
>  
It's been a long time since I've looked at machine code generated by
LLVM, but if I had to guess, I think it should be lowered into an
instruction that adjusts the stack pointer.  All alloca does is allocate
stack space; an adjustment of the stack pointer (on x86, decreasing it)
should suffice once the size of the allocation has been computed.

-- John T.

> Regards,
> Ryan
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>  

_______________________________________________
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: variable size alloca

Eli Friedman-2
In reply to this post by Ryan M. Lefever
On Tue, Sep 16, 2008 at 6:23 PM, Ryan M. Lefever <[hidden email]> wrote:
> To what do variable size LLVM alloca instructions get translated, when
> they are turned into machine code?  I compiled a piece of code to
> bitcode and disassembled it.  The disassembled code showed that there
> were alloca instructions with variable-sized parameters within the
> bitcode.  When I turned the bitcode into machine code, I performed an nm
> on the result but didn't see any symbols referring to alloca.  So, I'm
> guessing that they don't get translated to an alloca system call.  If
> that's the case, to what do they get translated?

It depends on your architecture/operating system, but it normally gets
transformed into arithmetic on the stack pointer.

-Eli
_______________________________________________
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: variable size alloca

Evan Cheng-2
In reply to this post by Ryan M. Lefever
Look for DYNAMIC_STACKALLOCK in various targets to see how they are  
handled. When alloca() is used, two things will happen. 1. The alloca  
will be translated into stack adjustment instruction(s). 2. CodeGen  
will make sure frame pointer is used even if frame pointer  
optimization is in effect.

Evan

On Sep 16, 2008, at 6:23 PM, Ryan M. Lefever wrote:

> To what do variable size LLVM alloca instructions get translated, when
> they are turned into machine code?  I compiled a piece of code to
> bitcode and disassembled it.  The disassembled code showed that there
> were alloca instructions with variable-sized parameters within the
> bitcode.  When I turned the bitcode into machine code, I performed  
> an nm
> on the result but didn't see any symbols referring to alloca.  So, I'm
> guessing that they don't get translated to an alloca system call.  If
> that's the case, to what do they get translated?
>
> Regards,
> Ryan
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

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