[LLVMdev] structure member alignment for vector types

Nicholas Chapman admin at indigorenderer.com
Sun Aug 18 15:37:19 PDT 2013


Hi All,
I have run into an issue when writing some LLVM code to read from a C++ 
structure.
The structure as defined in LLVM is { { <4 x float> }, { <4 x float> }, 
{ <16 x float> }, { <4 x float> }, { <4 x float> } }.
On Windows, with Visual Studio 2012, the vector members of the structure 
are packed tightly together.
However, LLVM seems to be leaving 32 bytes between the second 4 x float 
vector and the 16 x float vector.  This is maybe because the 16 x float 
vector
is getting aligned to 64 bytes inside the structure.
The result is that the JIT'd LLVM code is reading from the wrong memory 
location, resulting in errors.

Is this known behaviour of LLVM?  Presumably the structure layout is 
supposed to match that of the platform / Visual Studio?
Why would it leave a 32 byte gap anyway?

I'm using LLVM 3.2, on Windows 64 bit.

Cheers,
     Nick

-- 
Nicholas Chapman

Managing Director,
Glare Technologies Limited




More information about the llvm-dev mailing list