[LLVMdev] [Segmented Stacks] Week 1

Rafael Avila de Espindola rafael.espindola at gmail.com
Mon Jun 13 10:46:26 PDT 2011


On 11-06-02 07:47 PM, Peter Lawrence wrote:
> Guys,
> regarding alloca.
>
> not only are exceptions a problem here, but just plain old "longjmp".

Yes,
On IRC Sanjoy pointed out that it should be possible to handle this by 
changing longjmp. I am not sure it can be done in general. The alloca 
might have been called a dynamic number of times for example.

In fact, now that I think of it, the presence of longjmp pretty much 
forces a model where stacklets are not deallocated on return, just 
reused if stack grows again.

We discussed the use of allocas a bit in the rust channel. One idea that 
came out was that maybe we only need to support the "simple" case of 
allocas that are in the entry bb. That would still be a bit nasty as 
finding that size this late in the pipeline would not be trivial.

I think my suggestion for now would be to not support frames with 
allocas and afterwards, if time allows, we can add a llvm intrinsic that 
tells the codegen how much stack will be used by dynamic allocas. That 
way a FE that really wants split stacks and really wants dynamic allocas 
could write something like

define void @foo(i32 a, i32 b)  {
   %how_much_dynamic_space_this_frame_needs = add i32 %a, %b
   llvm.dynamic_alloca_use(%how_much_dynamic_space_this_frame_needs)
   %x = alloca i8, i32 a;
   %y = alloca i8, i32 b;
    ....
}

> -Peter Lawrence.
>

Cheers,
Rafael



More information about the llvm-dev mailing list