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

Dr. ERDI Gergo via llvm-dev llvm-dev at lists.llvm.org
Mon May 22 08:08:38 PDT 2017


On Mon, 22 May 2017, Dr. ERDI Gergo wrote:

> On Mon, 22 May 2017, Krzysztof Parzyszek via llvm-dev wrote:
>
>> Probably from LargeArrayMinWidth/LargeArrayAlign settings in Targets.cpp 
>> (in clang).
>
> Wait what? In clang? But my input is already LLVM IR. 
> MF->getDataLayout().getPrefTypeAlignment(Ty) must be basing its answer on 
> either something in the IR file, or in the target implementation, but clang 
> is not really in the picture.
>

Actually, tracking down the sequence of function calls, it turns out that 
'8' is ultimately coming from the following call in 
DataLayout::getAlignment:

getAlignmentInfo(AGGREGATE_ALIGN, 0, abi_or_pref, Ty);

this seems to return 8 with the following datalayout string:

e-S8:p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8

I think my problem is that 'a:8' probably doesn't mean what I think it 
should mean. What is the difference between 'a:8' and 'a:0'?


More information about the llvm-dev mailing list