[SelectionDAG] Clamp stack alignment for memset, memmove
authorHaohai Wen <haohai.wen@intel.com>
Wed, 26 Oct 2022 08:05:01 +0000 (16:05 +0800)
committerHaohai Wen <haohai.wen@intel.com>
Wed, 26 Oct 2022 08:45:31 +0000 (16:45 +0800)
commit21f23a37c6f1ba3f5ee34d505e527b1c6af8f99f
treef7381771bcff3e662afc5a244cad6cc63adede71
parent606634967da2a9ef06ce977e0ba0130a7146fc8c
[SelectionDAG] Clamp stack alignment for memset, memmove

memcpy has clamped dst stack alignment to NaturalStackAlignment if
hasStackRealignment is false. We should also clamp stack alignment
for memset and memmove. If we don't clamp, SelectionDAG may first
do tail call optimization which requires no stack realignment. Then
memmove, memset in same function may be lowered to load/store with
larger alignment leading to PEI emit stack realignment code which
is absolutely not correct.

Reviewed By: LuoYuanke

Differential Revision: https://reviews.llvm.org/D136456
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/test/CodeGen/AMDGPU/flat-scratch.ll
llvm/test/CodeGen/X86/memset-sse-stack-realignment.ll
llvm/test/CodeGen/X86/memset.ll
llvm/test/CodeGen/X86/pr42064.ll
llvm/test/DebugInfo/COFF/frameproc-flags.ll