This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Add an option to reserve physical registers from RA
ClosedPublic

Authored by Carrot on Aug 25 2022, 10:23 PM.

Details

Summary

This patch adds an option --reserve-regs-for-regalloc, so we can reserve a list of physical registers. These registers will not be used by register allocator, but can still be used as ABI requests such as passing arguments to function call.

Its main purpose is simulating high register pressure by reserving many physical registers. So it will be much easier to test and debug register allocation changes.

Diff Detail

Event Timeline

Carrot created this revision.Aug 25 2022, 10:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2022, 10:23 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
Carrot requested review of this revision.Aug 25 2022, 10:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2022, 10:23 PM

Do we actually need getReservedRegsForRA() to be something different from getReservedRegs()? Having getReservedRegs() return bogus values won't actually hurt anything, I think. The issue with the other patch was just that we don't want to expose feature flags that we know don't actually work.

Carrot added a comment.Sep 1 2022, 6:35 PM

It's not necessary strictly speaking. The only problem of getReservedRegs is it is used by isAnyArgRegReserved. Testing this new kind of reserved register in isAnyArgRegReserved doesn't make sense. A possible solution is moving current content of getReservedRegs to a new function getStrictlyReservedRegs, and call this function from getReservedRegs and isAnyArgRegReserved. I will try it.

Carrot updated this revision to Diff 457698.Sep 2 2022, 2:03 PM
efriedma added inline comments.Sep 2 2022, 2:15 PM
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
65

Maybe note in the description that this is intended for testing the register allocator.

303
Carrot updated this revision to Diff 457722.Sep 2 2022, 3:33 PM
Carrot marked an inline comment as done.
Carrot added inline comments.
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
303

It looks StringSet is more appropriate.

efriedma accepted this revision.Sep 2 2022, 6:08 PM

LGTM

This revision is now accepted and ready to land.Sep 2 2022, 6:08 PM
This revision was landed with ongoing or failed builds.Sep 6 2022, 10:20 AM
This revision was automatically updated to reflect the committed changes.