[LLVMdev] Vector troubles

Daniel Johansson danjo at wintermute.se
Sat Sep 29 05:51:34 PDT 2007


Chuck Rose III wrote:
>
> Hola LLVMers,
>
Hi Chuck,
>
> It is dying trying to store a our working vector into one of the LLVM 
> vectors created on the stack.  Despite the align-16 directive on the 
> alloca instruction, it is not always aligning to a 16-byte boundary. 
>
I also encountered this problem, and temporarily worked around this 
problem by using the __fastcall calling convention and aligning the 
stack pointer to a 16 byte boundary just before the function call... i.e 
something like:

ASSERT(fcnMain->getCallingConv() == llvm::CallingConv::X86_FastCall);
float (__fastcall *fcnMainPtr)(void*) = (float (__fastcall 
*)(void*))ctx->executionEngine().getPointerToFunction(fcnMain);

void* params = inputParams.get();
u32 oldStackPtr(0);
_asm
{
    mov oldStackPtr, esp
    and esp, 0xfffffff0
}
m_data[i] = fcnMainPtr(params);
_asm
{
    mov esp, oldStackPtr
}

This is clearly not platform independent (and also rather hacky), so a 
proper fix would be really nice indeed. I currently develop on windows, 
using MSVC 8.

Cheers,

-- Daniel Johansson




More information about the llvm-dev mailing list