[PATCH] D97193: [AArch64][SVE] Ensure hasFP has a consistent return value

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 24 14:14:20 PST 2021


efriedma added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64FrameLowering.cpp:379
+    // the large gains using a frame pointer can provide.
+    if (!AFI->hasCalculatedSVEShouldUseFP())
+      return true;
----------------
My team was testing out this patch internally, and this mechanism doesn't work quite as expected.

Specifically, changing the value of hasFP() after register allocation has a bad interaction with register scavenging.  If hasFP() returns false, the frame lowering code can decide to reserve FP as the emergency spill, so we don't allocate an emergency spill slot.  But register scavenging doesn't realize this: it queries MachineRegisterInfo::isReserved(), which is cached from before register allocation.  So in rare cases, scavenging can't find a register, and we can hit the fatal error "Cannot scavenge register without an emergency spill slot!"

One possible solution here is to change AArch64RegisterInfo::getReservedRegs() so it doesn't depend on hasCalculatedSVEShouldUseFP(), so the reserved registers don't change after regalloc.

Currently don't have a testcase I can share; let me know if you need one, and I'll try to come up with something.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97193



More information about the llvm-commits mailing list