[LLVMdev] Stack alignment in JIT compiled code

Anton Korobeynikov anton at korobeynikov.info
Thu Apr 30 15:48:02 PDT 2009

Hello, Simon

> So far, i found no way to denote calls to the host function as aligned
> or maintain stack alignment throughout the stack frame of the jit
> compiled function. Further, the gcc front end (llvm-g++ (GCC) 4.2.1)
> seems to ignore directives such as -mpreferred-stack-boundary.
Mike is right. It depends on your subtarget:

1. If you're running stuff on Darwin, which has 16-byte aligned stack,
then this is JIT bug
2. If you're running stuff on Linux/Windows which has 4 bytes aligned
stack, then it is a bug in your host code. It should not assume any
particular "extra" stack alignment as defined in platform ABI. And if
it does require such extra alignment it should do stack realignment by
itself (for example, LLVM itself does so if function is doing some
vector math which requires SSE2 code).

With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University

More information about the llvm-dev mailing list