[ARM] Fix access to stack arguments when re-aligning SP in Armv6m
authorMomchil Velikov <momchil.velikov@arm.com>
Fri, 2 Mar 2018 15:47:14 +0000 (15:47 +0000)
committerMomchil Velikov <momchil.velikov@arm.com>
Fri, 2 Mar 2018 15:47:14 +0000 (15:47 +0000)
commit505614bb4f695cb2d028726c8f37951f4ed831cf
tree5dd6f7f6266a2dd1d621e4f37bf07cb13430cd5b
parent36f14f41e6b8f1795cd041a2c9b2f98593cbea8c
[ARM] Fix access to stack arguments when re-aligning SP in Armv6m

When an Armv6m function dynamically re-aligns the stack, access to incoming
stack arguments (and to stack area, allocated for register varargs) is done via
SP, which is incorrect, as the SP is offset by an unknown amount relative to the
value of SP upon function entry.

This patch fixes it, by making access to "fixed" frame objects be done via FP
when the function needs stack re-alignment.  It also changes the access to
"fixed" frame objects be done via FP (instead of using R6/BP) also for the case
when the stack frame contains variable sized objects. This should allow more
objects to fit within the immediate offset of the load instruction.

All of the above via a small refactoring to reuse the existing
`ARMFrameLowering::ResolveFrameIndexReference.`

Differential Revision: https://reviews.llvm.org/D43566

llvm-svn: 326584
llvm/lib/Target/ARM/ARMFrameLowering.cpp
llvm/lib/Target/ARM/ThumbRegisterInfo.cpp
llvm/test/CodeGen/Thumb/frame-access.ll [new file with mode: 0644]