[PATCH] D11249: Fix PR#24142
Eric Christopher
echristo at gmail.com
Wed Jul 15 17:24:52 PDT 2015
Test?
On Wed, Jul 15, 2015, 5:07 PM Guozhi Wei <carrot at google.com> wrote:
> Carrot created this revision.
> Carrot added a subscriber: llvm-commits.
> Herald added a subscriber: aemerson.
>
> Function getSPAdjust doesn't consider the stack alignment, its usage in
> PEI::replaceFrameIndices causes wrong offset is used for stack objects.
>
> This patch adds a function to align the SP adjustment to the correct
> alignment, and call it from getSPAdjust and ARM backend. It can/should also
> be used by other backends if SP adjustment is need to be aligned.
>
> http://reviews.llvm.org/D11249
>
> Files:
> include/llvm/Target/TargetFrameLowering.h
> lib/CodeGen/TargetInstrInfo.cpp
> lib/Target/ARM/ARMFrameLowering.cpp
>
> Index: lib/Target/ARM/ARMFrameLowering.cpp
> ===================================================================
> --- lib/Target/ARM/ARMFrameLowering.cpp
> +++ lib/Target/ARM/ARMFrameLowering.cpp
> @@ -1783,8 +1783,7 @@
> // We need to keep the stack aligned properly. To do this, we
> round the
> // amount of space needed for the outgoing arguments up to the next
> // alignment boundary.
> - unsigned Align = getStackAlignment();
> - Amount = (Amount+Align-1)/Align*Align;
> + Amount = alignSPAdjust(Amount);
>
> ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
> assert(!AFI->isThumb1OnlyFunction() &&
> Index: lib/CodeGen/TargetInstrInfo.cpp
> ===================================================================
> --- lib/CodeGen/TargetInstrInfo.cpp
> +++ lib/CodeGen/TargetInstrInfo.cpp
> @@ -661,6 +661,7 @@
> return 0;
>
> int SPAdj = MI->getOperand(0).getImm();
> + SPAdj = TFI->alignSPAdjust(SPAdj);
>
> if ((!StackGrowsDown && MI->getOpcode() == FrameSetupOpcode) ||
> (StackGrowsDown && MI->getOpcode() == FrameDestroyOpcode))
> Index: include/llvm/Target/TargetFrameLowering.h
> ===================================================================
> --- include/llvm/Target/TargetFrameLowering.h
> +++ include/llvm/Target/TargetFrameLowering.h
> @@ -69,6 +69,20 @@
> ///
> unsigned getStackAlignment() const { return StackAlignment; }
>
> + /// alignSPAdjust - This method aligns the stack adjustment to the
> correct
> + /// alignment.
> + ///
> + int alignSPAdjust(int SPAdj) const {
> + if (SPAdj < 0) {
> + SPAdj = -SPAdj;
> + SPAdj = (SPAdj + StackAlignment - 1) / StackAlignment *
> StackAlignment;
> + SPAdj = -SPAdj;
> + } else {
> + SPAdj = (SPAdj + StackAlignment - 1) / StackAlignment *
> StackAlignment;
> + }
> + return SPAdj;
> + }
> +
> /// getTransientStackAlignment - This method returns the number of
> bytes to
> /// which the stack pointer must be aligned at all times, even between
> /// calls.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150716/83f59e6e/attachment.html>
More information about the llvm-commits
mailing list