[LLVMdev] measuring the stack size

Gordon Henriksen gordonhenriksen at mac.com
Thu Apr 17 10:39:18 PDT 2008

On Apr 17, 2008, at 13:00, Jonathan S. Shapiro wrote:

> On Thu, 2008-04-17 at 10:49 -0700, Chris Lattner wrote:
>> On Thu, 17 Apr 2008, guan mailist wrote:
>>> Does anyone have good ideas to dynamically measure the stack size  
>>> of a
>>> program by using LLVM. I am trying to add some new intrinsic  
>>> functions after each "alloca" in bitcode. Is it a good way to do  
>>> it? Any existing tools can help me to do so?
>> Depending on how much precision you need, you could use the  
>> llvm.frameaddress intrinsic.
> This prompts me to a related question. For procedures that do not  
> call alloca() at run time, is there a way to learn the stack frame  
> size in bytes for each procedure at static compile time?

The GC infrastructure exposes this information in a framework suitable  
for emitting metadata tables from a compiler plugin, if your interest  
lies in that direction.

— Gordon

More information about the llvm-dev mailing list