[Sparc] Don't overlap variable-sized allocas with other stack variables.
authorJames Y Knight <jyknight@google.com>
Tue, 25 Oct 2016 22:13:28 +0000 (22:13 +0000)
committerJames Y Knight <jyknight@google.com>
Tue, 25 Oct 2016 22:13:28 +0000 (22:13 +0000)
commit2e64b8b79e635295ab1614088a49883063c4541b
tree3e5fe87a95d73a8c8d911c34e057b91511143359
parent26a87bd0306cd9ac6754bf6039f79bd9c777f842
[Sparc] Don't overlap variable-sized allocas with other stack variables.

On SparcV8, it was previously the case that a variable-sized alloca
might overlap by 4-bytes the last fixed stack variable, effectively
because 92 (the number of bytes reserved for the register spill area) !=
96 (the offset added to SP for where to start a DYNAMIC_STACKALLOC).

It's not as simple as changing 96 to 92, because variables that should
be 8-byte aligned would then be misaligned.

For now, simply increase the allocation size by 8 bytes for each dynamic
allocation -- wastes space, but at least doesn't overlap. As the large
comment says, doing this more efficiently will require larger changes in
llvm.

Also adds some test cases showing that we continue to not support
dynamic stack allocation and over-alignment in the same function.

llvm-svn: 285131
llvm/lib/Target/Sparc/SparcISelLowering.cpp
llvm/test/CodeGen/SPARC/2013-05-17-CallFrame.ll
llvm/test/CodeGen/SPARC/fail-alloca-align.ll [new file with mode: 0644]
llvm/test/CodeGen/SPARC/stack-align.ll