[PATCH] D10826: Fix AArch64 prologue for empty frame with dynamic allocas
Tim Northover
t.p.northover at gmail.com
Thu Jul 9 14:52:07 PDT 2015
t.p.northover added inline comments.
================
Comment at: lib/Target/AArch64/AArch64FrameLowering.cpp:356-362
@@ -355,5 +355,9 @@
// Use the first callee-saved register as a scratch register
- assert(MF.getRegInfo().isPhysRegUsed(AArch64::X9) &&
- "No scratch register to align SP!");
- scratchSPReg = AArch64::X9;
+ if (MF.getRegInfo().isPhysRegUsed(AArch64::X9)) {
+ scratchSPReg = AArch64::X9;
+ } else if (RegInfo->hasBasePointer(MF)) {
+ scratchSPReg = RegInfo->getBaseRegister();
+ } else {
+ report_fatal_error("No scratch register to align SP!");
+ }
}
----------------
kristof.beyls wrote:
> I think slightly nicer/better logic is
> if (RegInfo->hasBasePointer(MF))
> scratchSPReg = RegInfo->getBaseRegister();
> else
> scratchSPReg = AArch64::X9;
> assert(MF.getRegInfo().isPhysRegUsed(scratchSPReg) &&
> "No scratch register to align SP!");
>
> With the above code, a few small tweaks to the tests in test/CodeGen/AArch64/aarch64-dynamic-stack-layout.ll are needed (to use the base pointer X19 instead of X9 for a few tests). When both X9 and X19 are available as scratch registers it's an arbitrary decision which one to use.
Can't we just nick any temporary register we please (I think the original comment miscategorises X9) and make sure it's used?
scratchSPReg = AArch64::X9;
MF.getRegInfo().setPhysRegUsed(scratchSPReg); // Take that!
http://reviews.llvm.org/D10826
More information about the llvm-commits
mailing list