Enabling the register allocation infrastructure
Assuming you use the default machine pass pipeline that we described in Chapter 13, the register allocation infrastructure is already up and running. If you did not instantiate the default machine pass pipeline, you will need to manually add the passes involved in the register allocation process yourself, starting with the register coalescer phase (using the RegisterCoalescerID variable), then the register assignment phase (for instance, using the createGreedyRegisterAllocator function), and so on, following what you learned in Chapter 5.
Irrespective of how you connect the register allocation infrastructure, as soon as you have something resembling what the default machine pass pipeline does, the whole register allocation process just works with one caveat: you cannot spill any variable.
Spilling occurs when the register assignment phase runs out of registers and splitting the live ranges of the variables is not enough to relax...