This is an archive of the discontinued LLVM Phabricator instance.

[greedyalloc] Return early when there is no register to allocate.
ClosedPublic

Authored by LuoYuanke on Jun 29 2022, 4:31 AM.

Details

Summary

In X86 we split greddy register allocation into 2 passes. The 1st pass
is to allocate tile register, and the 2nd pass is to allocate the rest
of virtual register. In most cases there is no tile register, so the 1st
pass is unnecessary. To improve the compiling time, we check if there is
any register need to be allocated by invoking callback
ShouldAllocateClass. If there is no register to be allocated, just
return false in the pass. This would improve the 1st greed RA pass for
normal cases.

Diff Detail

Event Timeline

LuoYuanke created this revision.Jun 29 2022, 4:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2022, 4:31 AM
LuoYuanke requested review of this revision.Jun 29 2022, 4:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2022, 4:31 AM

@nikic , could you help to check if this patch can fix the regression caused by D128584?

lkail added a subscriber: lkail.Jun 29 2022, 5:14 AM
nikic added a comment.Jun 29 2022, 8:26 AM

@nikic , could you help to check if this patch can fix the regression caused by D128584?

Yes, looks like it fixed the regression, or at least most of it: http://llvm-compile-time-tracker.com/compare.php?from=66a16b2848b434e937d658f15fc1849650f52185&to=67bc0ed77803965cf986e79674f16305e0c503b2&stat=instructions

xiangzhangllvm added inline comments.Jun 29 2022, 5:44 PM
llvm/lib/CodeGen/RegAllocGreedy.cpp
2521

The logic is no problem.
Do you mind move the code to a function (e.g. hasVirtRegAlloc() ) to make the RAGreedy::runOnMachineFunction clean ?

LuoYuanke added inline comments.Jun 29 2022, 6:16 PM
llvm/lib/CodeGen/RegAllocGreedy.cpp
2521

Sure, I'll update the patch.

LuoYuanke updated this revision to Diff 441224.Jun 29 2022, 6:34 PM

Address Xiang's comments.

This revision is now accepted and ready to land.Jun 29 2022, 6:36 PM
This revision was landed with ongoing or failed builds.Jun 29 2022, 8:12 PM
This revision was automatically updated to reflect the committed changes.