For a research project, I want a MIR program transformation that creates a place alias after every mutable borrow such that subsequent borrows use the new alias. For example:
I would assume that mk_place_alias has to be special cased in borrowck code (like retag) to be ignored or alternatively be added after borrowck.
Should this instruction be put into MIR from the start or can it be added in a later dialect/phase? For a later phase how would I go about replaceAllUsesOfPlaceWithAlias(...)? Are there examples of this?
(If you want it renumbered for human reading convenience, you can use -Zmir-enable-passes=+ReorderLocals -- there's an existing pass to renumber everything.)
I believe so. I want to represent that a &mut creates a borrow and redefines the place in MIR syntax.
The (above) snippet is the end goal. My current understanding is that this LLVM code is straightforward to generate if I change the semantics of borrow in MIR itself.