[LLVMdev] Register allocation in two passes
Jakob Stoklund Olesen
stoklund at 2pi.dk
Wed Nov 30 13:42:17 PST 2011
On Nov 30, 2011, at 12:17 PM, Borja Ferrer wrote:
> Thanks for all the hints Jakob, I've added the following piece of code after the spill code handling inside selectOrSplit() (ignoring some control logic):
>
> for (LiveIntervals::const_iterator I = LIS->begin(), E = LIS->end(); I != E;
> ++I)
> {
> unsigned VirtReg = I->first;
> if ((TargetRegisterInfo::isVirtualRegister(VirtReg))
> && (VRM->getPhys(VirtReg) == REG_Y))
> {
> LiveInterval &LI = LIS->getInterval(VirtReg);
> unassign(LI, REG_Y);
> enqueue(&LI);
> }
> }
> RegClassInfo.runOnMachineFunction(VRM->getMachineFunction()); // update reserve reglist
>
> So similar to what's done in LRE_WillShrinkVirtReg(), it searches for live intervals where REG_Y is allocated and evicts them for reallocation. I don't know if there's a faster way of doing this but it's working :)
Looks good.
It is probably faster to scan the LiveIntervalUnion for REG_Y for assigned virtual registers, but the above code will work just fine.
Technically, you should also check REG_Y's aliases, but there probably aren't any.
> About your first question: the register has to be reserved throughout the whole function.
>
> Thanks for the help
Glad to help.
/jakob
More information about the llvm-dev
mailing list