Register allocation
The basic task of the register allocation is to transform an endless number of virtual registers into physical (limited) ones. Since targets have a limited number of physical registers, some virtual registers are assigned to memory locations, the spill slots. Yet, some MI code fragments may already be using physical registers even before register allocation. This happens for machine instructions that need to use a specific register to write their result or because of an ABI requirement. For these cases, the register allocator respects this previous allocation and work to assign other physical registers to the remaining virtual registers.
Another important role of the LLVM register allocator is to deconstruct the SSA form of the IR. Up until this point, the machine instructions may also contain phi instructions that were copied from the original LLVM IR and are necessary to support the SSA form. In this way, you can implement machine-specific optimizations with the comfort...