The check was refactored to become publically available here: ProvableHQ/snarkVM#3051.
We should emit an error when running leo upgrade similar to https://github.com/ProvableHQ/leo/blob/b0fa4056dcc48bae658522d61896555a1a7a4a4c/leo/cli/commands/upgrade.rs#L440C40-L440C62
and propose some workarounds. Sadly, there are no good workarounds. Some options:
- Use a whole new function and deprecate the old one. (without removing it of course).
- If the offending register in the new edition has a smaller index than in the old edition, then we can suggest adding redundant instructions to the bytecode to get us up to the old index again.