Inserting/Creating A New Function at MIR level

Hi all, I am working on some compiler optimizations, and I was wondering whether it's possible to insert/create new functions at MIR level. I know this kind of thing is possible in LLVM because it has Module level passes, but MIR passes take a Body. If this is possible, I would appreciate any advice in the possible direction, and if not, any advice on any alternatives would be very much appreciated.

Thanks a lot in advance.

This is not currently possible. MIR optimizations run on a single function at a time. With the new support for query feeding inside the compiler it would theoretically be possible to support this by creating a new def and feeding it the results of the right queries, but I don't know which queries you all need to feed the results for and you will have to modify rustc_metadata to actually encode the MIR for the new definition.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.