[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:55:49 PDT 2019


Hi Tim,

I have implemented all the steps to register a target backend for LLVM and so far I’m doing ok with it, but I do not know how to select a particular target on Clang. I just modified the “TargetInfo.cpp” file as I posted on my previous email to get 16 bit ints. So, any more insights will be appreciated.

On the other hand I’m unable to find LargeArrayMinSize in any project files (not even in lib/Basic/Targets/X86.cpp) and  LargeArrayAlign is only in TargetInfo.h and TargetInfo.cpp which is set to a value of 0 (Zero)

I'm on version 7.0.1,

What am I missing?

Joan Lluch

Tel: 620 28 45 13

> On 5 May 2019, at 18:22, Tim Northover <t.p.northover at gmail.com <mailto:t.p.northover at gmail.com>> wrote:
> 
> Hi Joan,
> 
> On Sun, 5 May 2019 at 17:09, Joan Lluch via llvm-dev
> <llvm-dev at lists.llvm.org <mailto: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.
> 
> Cheers.
> 
> Tim.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190505/97c06d53/attachment.html>


More information about the llvm-dev mailing list