[RFC] make llvm register mutable

Llvm ir can be mutable. Just make a conversion to ssa in the hood. This is very convinent to the user. Of cause we can use memory operation to mimic mutable register. It’s easy too. But it’s not very obvious. And not all languages want to use memory directly. Llvm is the right place to implement that to avoid making wheels. As far as I know, some body already implement mem2reg. I think the work can be done father.

The change will not affect the core function of llvm. But it’s good for the user. Right now I don’t see bad side of it.


I’m not sure I understand what you’re trying to do.
LLVM IR doesn’t have registers, so I’m assuming you’re talking about values.

Values are by construction SSA and this is not something that can be changed easily (and regardless, I don’t think we want to allow non-SSA values in LLVM IR).

At this point I would suggest two possible ways:

  1. Use memory load/store and rely on mem2reg to reconstruct SSA for you
  2. Work at the MachineIR level. This level allows non-SSA code to exists.