This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Correctly recognize -reserve-regs-for-regalloc=X30,X29
ClosedPublic

Authored by Carrot on Nov 10 2022, 6:01 PM.

Details

Summary

In AArch64 backend X30 is named as LR, X29 is named as FP. So the code in AArch64Subtarget::AArch64Subtarget can't recognize these 2 registers.

for (unsigned i = 0; i < 31; ++i) {
   if (ReservedRegNames.count(TRI->getName(AArch64::X0 + i)))
     ReserveXRegisterForRA.set(i);
 }

This patch add code to explicitly handle these 2 registers.

Diff Detail

Event Timeline

Carrot created this revision.Nov 10 2022, 6:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2022, 6:01 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
Carrot requested review of this revision.Nov 10 2022, 6:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2022, 6:01 PM
dmgreen accepted this revision.Nov 21 2022, 10:38 PM

Oh I see, because the order of the registers means that AArch64::X0+30 != LR.

I'm not sure if it really makes a lot of sense to reserve these regs, but this sounds like a good fix. LGTM.

This revision is now accepted and ready to land.Nov 21 2022, 10:38 PM