It still can be done much cheaper. I just fixed my excessively cheap register allocator for my c compiler rcc.
The register allocator is a simple first-fit bitmask with no spilling to stack except for the two predefined spill slots. Only if all 8 registers are in use, it spills the additional registers on the stack.
What they call guest registers.
No SSA and no BB needed. No crazy mem2reg or graph-coloring. Only once per function.
Only for very big functions one register is spilled, usually just rsi.
The register allocator is a simple first-fit bitmask with no spilling to stack except for the two predefined spill slots. Only if all 8 registers are in use, it spills the additional registers on the stack. What they call guest registers. No SSA and no BB needed. No crazy mem2reg or graph-coloring. Only once per function.
Only for very big functions one register is spilled, usually just rsi.
Benchmarks: