[llvm-dev] How to get CLang array alloca alignments to be smaller than 16 bytes?
Joan Lluch via llvm-dev
llvm-dev at lists.llvm.org
Sun May 5 09:09:15 PDT 2019
I am working on a custom LLVM backend for a 16 bit architecture.
For my architecture, I need smaller array alignments for arrays created on the stack.
For example, consider the following code at the start of a C function:
char localBuff[20];
char localBuff2[6];
this gets converted by Clang into this:
%localBuff = alloca [20 x i8], align 16
%localBuff2 = alloca [6 x i8], align 1
Note that char arrays smaller than 16 bytes are specified to be aligned to 1 byte, but bigger ones are aligned to 16 bytes.
On the LLVM backend, this creates bigger than necessary frame index offsets, which are undesirable for my architecture.
As a side note, my target machine is 16 bits, so I have already modified ‘TargetInfo.ccp' with 16 bit ints and pointers, which works like a charm
PointerWidth = PointerAlign = 16;
IntWidth = IntAlign = 16;
The Question is:
- How do I make CLang to emit code with smaller array alignment, say 2 or 4 byte aligned arrays?
- Otherwise, is there a way to override that alignment on the LLVM backend implementation, particularly to get it create frame index offsets aligned by a smaller size, thus ignoring the clang specified alignment?
Joan Lluch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190505/1c60bea2/attachment.html>
More information about the llvm-dev
mailing list