[llvm-dev] How exactly is datatype alignment determined?

Dr. ERDI Gergo via llvm-dev llvm-dev at lists.llvm.org
Mon May 22 05:49:39 PDT 2017


Hi,

I'm seeing a bug in the AVR backend that seems to be caused by LLVM 
thinking things will be aligned to 8 bytes whereas they are unaligned. 
Specifically, MF->getDataLayout().getPrefTypeAlignment(Ty) returns 8 for 
the following two types:

%opt = type { i8, [0 x i8], [3 x i8] }
%Machine = type { i16, [0 x i8], i16, [0 x i8], [16 x i8], [0 x i8] }

The target datalayout specifies that pointers are aligned to 8 bits (i.e. 
unaligned), so I would expect getPrefTypeAlignment to return 1:

target datalayout = "e-S8:p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8"

So where does that datatype alignment result of 8 come from?

Thanks,
 	Gergo


More information about the llvm-dev mailing list