[SelectionDAG] Don't promote the alignment of allocas beyond the stack alignment.
authorEli Friedman <efriedma@quicinc.com>
Wed, 6 May 2020 19:06:29 +0000 (12:06 -0700)
committerEli Friedman <efriedma@quicinc.com>
Tue, 12 May 2020 00:39:00 +0000 (17:39 -0700)
commitc9c930ae67c38b93451aa979de723723aec0067d
tree627a5bddc7d4822ea792a6dd567c263544454266
parent117e5609e98b43f925c678b72f816ad3a1c3eee7
[SelectionDAG] Don't promote the alignment of allocas beyond the stack alignment.

allocas in LLVM IR have a specified alignment. When that alignment is
specified, the alloca has at least that alignment at runtime.

If the specified type of the alloca has a higher preferred alignment,
SelectionDAG currently ignores that specified alignment, and increases
the alignment. It does this even if it would trigger stack realignment.
I don't think this makes sense, so this patch changes that.

I was looking into this for SVE in particular: for SVE, overaligning
vscale'ed types is extra expensive because it requires realigning the
stack multiple times, or using dynamic allocation. (This currently isn't
implemented.)

I updated the expected assembly for a couple tests; in particular, for
arg-copy-elide.ll, the optimization in question does not increase the
alignment the way SelectionDAG normally would. For the rest, I just
increased the specified alignment on the allocas to match what
SelectionDAG was inferring.

Differential Revision: https://reviews.llvm.org/D79532
llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
llvm/test/CodeGen/AArch64/sve-alloca-stackid.ll
llvm/test/CodeGen/AMDGPU/private-element-size.ll
llvm/test/CodeGen/AMDGPU/stack-pointer-offset-relative-frameindex.ll
llvm/test/CodeGen/ARM/alloc-no-stack-realign.ll
llvm/test/CodeGen/Thumb2/mve-basic.ll
llvm/test/CodeGen/X86/arg-copy-elide.ll
llvm/test/CodeGen/X86/avx2-vbroadcast.ll
llvm/test/CodeGen/X86/avx512-intel-ocl.ll
llvm/test/CodeGen/X86/load-local-v3i129.ll
llvm/test/CodeGen/X86/movtopush.ll