[llvm-dev] A struct {i8,i64} has size == 12, clang says size 16
edA-qa mort-ora-y via llvm-dev
llvm-dev at lists.llvm.org
Wed Apr 18 12:04:55 PDT 2018
I'm creating a struct of `{i8,i64}` and `DataLayout::getTypeAllocSize`
is returning `12`. `getStructLayout` also gives an `4` offset for the
second element.
The native ABI, and clang, for the same type are producing a size of 16,
with an alignment of 8, for the second element.
This is for the system triple "x86_64-linux-gnu"
What could be causing this difference in alignment and how can I fix it?
I'm verifying the native ABI with:
// clang -emit-llvm ll_struct_arg.c -S -o /dev/tty
#include <stddef.h>
typedef struct vpt_data {
_Bool c;
long int b;
} vpt_data;
int main() {
vpt_data v;
vpt_test(v);
auto a = sizeof(v);
auto off = offsetof(vpt_data,b);
}
16 is stored to `a` and 8 to `off`.
--
edA-qa mort-ora-y
http://mortoray.com/
Creator of the Leaf language
http://leaflang.org/
Streaming algorithms, AI, and design on Twitch
https://www.twitch.tv/mortoray
Twitter
edaqa
More information about the llvm-dev
mailing list