[PATCH] D41131: [AArch64] Implement stack probing for windows
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 12 14:19:04 PST 2017
mstorsjo added inline comments.
================
Comment at: lib/Target/AArch64/AArch64FrameLowering.cpp:597
+ break;
+ }
+
----------------
compnerd wrote:
> Is this something that Visual Studio supports? Or the code model an extension like the ARMv7 case?
I modeled this based on what MSVC produces. It's pretty similar to the ARMv7 case, with one difference: On ARM, on return from `__chkstk`, the register has been rescaled into bytes, so you do `sub sp, sp, r4`, while here it's kept in the same unit as on input to `__chkstk`, and thus need to do `sub sp, sp, x15, lsl #4`.
================
Comment at: lib/Target/AArch64/AArch64FrameLowering.cpp:1224-1226
+ unsigned BasePointerReg = AArch64::NoRegister;
+ if (RegInfo->hasBasePointer(MF))
+ BasePointerReg = RegInfo->getBaseRegister();
----------------
compnerd wrote:
> Id just use a ternary:
>
> unsigned BP = RegInfo->hasBasePointer(MF) ? RegInfo->getBaseRegister() : AArch64::NoRegister;
Sure, I can do that.
================
Comment at: lib/Target/AArch64/AArch64FrameLowering.cpp:1229
+ unsigned SpillEstimate = 0;
+ for (unsigned i = 0; CSRegs[i]; ++i)
+ if (CSRegs[i] == BasePointerReg)
----------------
compnerd wrote:
> Why not use a range based loop?
>
> for (const auto &CSR : RegInfo->getCalleeSavedRegs(&MF))
> if (CSR == BasePointerReg)
> ++SpillEstimate;
That doesn't work, since `getCalleeSavedRegs` returns a plain pointer with null termination, the length isn't known at compile time and it doesn't have `begin()`/`end()` functions.
https://reviews.llvm.org/D41131
More information about the llvm-commits
mailing list