[PATCH] D57183: [COFF, ARM64] Fix localaddress to handle stack realignment

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 24 17:13:06 PST 2019


rnk added a comment.

In D57183#1370450 <https://reviews.llvm.org/D57183#1370450>, @mgrang wrote:

> In D57183#1370366 <https://reviews.llvm.org/D57183#1370366>, @efriedma wrote:
>
> > If there's a call to localaddress in a function without funclets or VLAs, we should use sp, yes.  That should be rare in practice, but I guess the testcase is an example.
>
>
> So I guess the logic should be something like this:
>
>   if (!hasVarSizedObjects && !hasFunclets) --> use SP
>   else if (needsStackRealignment) --> use BP
>   else --> use FP
>


Is that not what the existing code does? `RegInfo->getFrameRegister(MF)` does this to choose between SP and FP:

  unsigned
  AArch64RegisterInfo::getFrameRegister(const MachineFunction &MF) const {
    const AArch64FrameLowering *TFI = getFrameLowering(MF);
    return TFI->hasFP(MF) ? AArch64::FP : AArch64::SP;
  }

And hasBasePointer checks the same conditions you've listed here.

...

I see, hasFP returns true when there are calls and the stack frame is large, and also in this case:

  // Win64 SEH requires frame pointer if funclets are present.
  if (MF.hasLocalEscape())
    return true;

Are you sure we still want that there? It sounds like we are trying to allow addressing variables with SP when localescape is present.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57183/new/

https://reviews.llvm.org/D57183





More information about the llvm-commits mailing list