[llvm-commits] Segmented stacks, current status.

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Tue Jun 28 09:05:47 PDT 2011


On 06/27/2011 10:23 AM, Sanjoy Das wrote:
> Hi!
>
> I am a GSoC student, working on implementing segmented stacks for LLVM.
> I have attached a set of patches that add preliminary support for
> segmented stacks and variable length allocas for review. The code is
> also available on Github [1].

In getScratchRegister you have:

+// Returns a register that is neither alive when entering the function or
+// callee-saved.

but the function then looks for a callee saved register that is not live 
in. Can we be sure that one is always available? Looking at gold (if you 
plan to use it for linking segmented and non segmented code), it looks 
like it assumes r10 or r11 is used.

+    TlsReg = X86::FS;
+    TlsOffset = 0x70;

Being linux only is probably fine for now. Anyone familiar with how OS X 
does TLS? If it is similar enough maybe we can just put these constants 
in a subtarget.

+  // Read the limit off the current stacklet off the stack_guard location.
+  if (Is64Bit) {

You are computing "stacklimit + size" and comparing rsp with it. Looks 
like gold assume a lea NN(%rs) to compute rs-size and that then gets 
compared with stacklimit. That also saves one instruction, no?

-  assert((Subtarget->isTargetCygMing() || Subtarget->isTargetWindows()) &&
+  assert((Subtarget->isTargetCygMing() || Subtarget->isTargetWindows() ||
+          EnableSegmentedStacks) &&
           "This should be used only on Windows targets"

The comment is stale :-)


Dose __morestack_allocate_stack_space takes care of linking the memory 
so that when this function is called again we don't allocate another 
lange block?

> The code, in the current state, does not support varargs.
>
> Thanks!
>
> [1] https://github.com/sanjoy/llvm/tree/segmented-stacks
>

Thanks!

Cheers,
Rafael



More information about the llvm-commits mailing list