[LLVMdev] Preferred alignment of globals > 16bytes
clattner at apple.com
Fri Sep 7 10:13:45 PDT 2012
On Sep 7, 2012, at 8:02 AM, Richard Osborne <richard at xmos.com> wrote:
>>> I was a bit surprised to see these numbers hardcoded in TargetData since everything else is taken from the datalayout string. I was wondering what the logic was behind the number 16. Would it make sense to derive this number from the other alignments somehow (e.g. the maximum preferred alignment across all types). Alternatively would it make sense to make it configurable in the datalayout string?
>> I don't think that there is any specific logic to it. It was just a heuristic that "made sense at the time", not based on any scientific evaluation. If you want to raise it to some other arbitrary limit (say 32 bytes) that would be fine given some performance analysis. If you want to design a way to express this in target data, please propose a specific way to model it.
> I want it to be configurable. On my target there is no advantage to aligning anything by more than a 4 bytes - it just wastes space. I'll try to put together a proposal for making it possible to set this per target.
Ok, after considering this a bit more, how about we take a different approach: despite its name, TargetData is really mostly for consumption by the mid-level optimizers. getPreferredAlignment is really something that only TargetLowering[ObjectFile] should be using. What do you think about sinking getPreferredAlignment down to it? This will make it much easier to target-hookize this.
More information about the llvm-dev