Hey everyone,
I am working on a project on a verifier for Rust and basically I am trying to automatically add some sort of runtime checks into the generated executables.
This would require me to get a mutable version of the MIR, that can be fed back to the compiler. I would prefer to do this on the MIR level, since most of the analysis of our tool happens on this level anyways. Modifying the AST might also be an option, in case that is significantly simpler to modify.
However, we would like to avoid forking the compiler and do this by using rustc's interface only, but so far all the ideas I had / previous suggestions on forums I found lead me nowhere.
- things like registering custom MirPasses have been deprecated since apparently this is a misuse of them.
- I was hoping I could override a query like
mir_built
, replicate its original behavior and add some additional modifications. However, it seems like the "replicating its original behavior" is not really possible since most of the used functions and types are private.
So yeah, I would be very happy about any feedback, suggestions or help of any kind. Is there still a intended way of mutating the MIR from a compiler plugin? If so, how? If not, what might be a sensible way to "hack" it?
Also, as mentioned above, I've looked into ways of modifying the AST as well, but so far it seems like the same problems apply there. If there's easier ways for the ast than mir I would also greatly appreciate any pointers.
Cheers