This is an archive of the discontinued LLVM Phabricator instance.

[WIP] Cleanup SplitCSR implementation
AbandonedPublic

Authored by reames on Nov 30 2016, 8:45 PM.

Details

Reviewers
MatzeB
Summary

Very much WIP, posting for discussion, will cleanup based on input.

Key question: Is minimal phys reg the right helper routine to be using here? The ARM backend change makes me wonder. It does match what the x86 backend uses for non-GPR spills along the "normal" spill insertion path.

SplitCSR is an off by default mode which let's the register allocator handle spilling CSRs as normal vregs. This really should be the default, but for historical reasons isn't.

This change tries to remove the target specific differences from the copied implementations. Once this is in, a simple NFC change will sink a shared implementation into the base class and delete all of the overrides.

Diff Detail

Event Timeline

reames updated this revision to Diff 79861.Nov 30 2016, 8:45 PM
reames retitled this revision from to [WIP] Cleanup SplitCSR implementation.
reames updated this object.
reames added a reviewer: MatzeB.
reames added a subscriber: llvm-commits.
MatzeB edited edge metadata.Nov 30 2016, 8:55 PM

I think getMinimalPhysRegClass() may be more restrictive than necessary (I imagine you can end up the class for A B C D as the smallest class on X86 while the full GPR class would be more suitable on X86). I don't think we have a better generic notion today, so all that is left is to enumerate register classes that allow suitable spilling and cheaply copying between the registers inside the class.

There is also some bad code duplication going on here today. I think we solve the same (or really similar) problem in LowerFormalArguments() and LowerReturn().

I think getMinimalPhysRegClass() may be more restrictive than necessary (I imagine you can end up the class for A B C D as the smallest class on X86 while the full GPR class would be more suitable on X86). I don't think we have a better generic notion today, so all that is left is to enumerate register classes that allow suitable spilling and cheaply copying between the registers inside the class.

That said I think I would be fine to use getMinimalPhysRegClass() for the cases not covered by the explicit enumeration.

[speaking of getMinimanRCForPhysReg] I don't think we have a better generic notion today,

I concur, we don't have a better generic notion.

so all that is left is to enumerate register classes that allow suitable spilling and cheaply copying between the registers inside the class.

I would expect this to be a non-problem. The splitting mechanism should relax the constraints if need be. Therefore, yes, at first it will be overconstrained, but when split, it will not. The bottom line is that I am not sure the added enumeration is worth bothering, but this is a trade-off.
I don't mind either way.

lib/Target/ARM/ARMISelLowering.cpp
13381

Put the dump changes into a different patch.

lib/Target/X86/X86ISelLowering.cpp
33766

I would rather you get to the bottom of this than having this comment.
Check with Manman.

reames abandoned this revision.Jan 2 2018, 9:17 AM

Don't have time to get back to this.