[SPARC] Fix stupid oversight in stack realignment support.
authorJames Y Knight <jyknight@google.com>
Wed, 26 Aug 2015 17:57:51 +0000 (17:57 +0000)
committerJames Y Knight <jyknight@google.com>
Wed, 26 Aug 2015 17:57:51 +0000 (17:57 +0000)
commit044c4e6484bb39289e994583d0ec42c34e89ae60
tree94166622d70e9b2d213beec5c51401aad5f8797c
parent7a65f99c130db1886f7aa8ad842e961a17868572
[SPARC] Fix stupid oversight in stack realignment support.

If you're going to realign %sp to get object alignment properly (which
the code does), and stack offsets and alignments are calculated going
down from %fp (which they are), then the total stack size had better
be a multiple of the alignment. LLVM did indeed ensure that.

And then, after aligning, the sparc frame code added 96 (for sparcv8)
to the frame size, making any requested alignment of 64-bytes or
higher *guaranteed* to be misaligned. The test case added with r245668
even tests this exact scenario, and asserted the incorrect behavior,
which I somehow failed to notice. D'oh.

This change fixes the frame lowering code to align the stack size
*after* adding the spill area, instead.

Differential Revision: http://reviews.llvm.org/D12349

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246042 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/Sparc/SparcFrameLowering.cpp
lib/Target/Sparc/SparcFrameLowering.h
lib/Target/Sparc/SparcSubtarget.cpp
test/CodeGen/SPARC/stack-align.ll