So it appears that in a lot of cases before registerbanks are selected, we dont have Register classes and MIR-Canon is crashing. This attempts to fix this by creating new override registers that use the generic type rather than the register class.
I think that the do is superfluous
I think that this can just be return MRI.getRegClassOrNull(VReg0) || MRI.getType(VReg0) == MRI.getType(VReg1);
Why not sink the get into the conditional?
if (auto RC = MRI.getRegClassOrNull(VReg)) return MRI.createVirtualRegister(RC, OS.str());
Going to leave out the vregTypesMatch part as that changes some of the behavior in a way that causes llvm/test/CodeGen/MIR/AMDGPU/mir-canon-multi.mir to fail, and I'd like to understand why that is happening. But for now this change makes the cursor create vregs based on the vreg type if there is no register class to base off of.