[llvm-dev] How to get CLang array alloca alignments to be smaller than 16 bytes?

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Sun May 5 09:22:36 PDT 2019

Hi Joan,

On Sun, 5 May 2019 at 17:09, Joan Lluch via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> this gets converted by Clang into this:
>   %localBuff = alloca [20 x i8], align 16
>   %localBuff2 = alloca [6 x i8], align 1

Is that when Clang is compiling for your target, or maybe you copied
x86 code into your target?

Because this ought to be controlled by "LargeArrayMinSize" and
"LargeArrayAlign" in lib/Basic/Targets/XYZ.cpp, and only x86 and
WebAssembly seem to set the value to 16. The default never increases
the alignment as far as I can tell.

> - 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?

I don't think it's the kind of thing you can (or should) override in
the backend. Other bits of code could have been relying on it from the
start (e.g. to store 3 bits of whatever in the low part of a pointer),
and earlier optimizations might have made even more assumptions based
on that value.



More information about the llvm-dev mailing list