[llvm] [CodeGen] Add assertion to MachineBasicBlock::addLiveIn and friends (PR #140527)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 23 09:45:22 PST 2025
topperc wrote:
> Thanks. But if it's always supposed to be physical, should we be using MCPhysReg instead of
MCRegister?
MCPhysReg is just a typedef for uint16_t so it has no type safety.
Ideally MCRegister would be physical register only, but both WebAssembly and NVPTX use MCRegister range outside the MCPhysReg range to represent "virtual" registers in their final assemlby. They don't go through normal register allocation. These virtual registers are created explicitly in WebAssemblyAsmPrinter and NVPTXAsmPrinter and are added to MCInsts.
We can probably add an assertion to implicit conversions from Register to MCRegister to only allow invalid and physical registers to convert. I've also thought about adding a second argument to the MCRegister constructor to indicate whether it's valid to create a "virtual" MCRegister. This flag would default to false and would only need to be set for WebAssembly and NVPTX.
https://github.com/llvm/llvm-project/pull/140527
More information about the llvm-commits
mailing list