[X86] Generate unaligned access for fixed slots in unaligned stack
authorMatheus Izvekov <mizvekov@gmail.com>
Fri, 5 Feb 2021 02:51:47 +0000 (10:51 +0800)
committerWang, Pengfei <pengfei.wang@intel.com>
Fri, 5 Feb 2021 03:36:54 +0000 (11:36 +0800)
commit1ac98044dfc250a0454762eb49f138b1f3f035e7
tree5946dc7bf9dbaa7edd3ea2f0380c60b83854db4f
parent11ef356d9e3a957fdee16b004c7b8c530ca68a9a
[X86] Generate unaligned access for fixed slots in unaligned stack

loadRegFromStackSlot()/storeRegToStackSlot() can generate aligned access
instructions for stack slots even if the stack is unaligned, based on the
assumption that the stack can be realigned.
However, this doesn't work for fixed slots, which are e.g. used for
spilling XMM registers in a non-leaf function with
`__attribute__((preserve_all))`.
When compiling such code with `-mstack-alignment=8`, this causes general
protection faults.

Fix it by only considering stack realignment for non-fixed slots.

Note that this changes the output of three existing tests which spill AVX
registers, since AVX requires higher alignment than the ABI provides on
stack frame entry.

Reviewed By: rnk, jyknight

Differential Revision: https://reviews.llvm.org/D73126
llvm/lib/Target/X86/X86InstrInfo.cpp
llvm/test/CodeGen/X86/anyregcc.ll
llvm/test/CodeGen/X86/avx-intel-ocl.ll
llvm/test/CodeGen/X86/avx512-intel-ocl.ll
llvm/test/CodeGen/X86/x86-64-xmm-spill-unaligned.ll [new file with mode: 0644]