Getting non-optimized, but analyzed MIR

Hello!

I'm currently implementing a tool for Rust analysis. I would like to obtain MIR code that has not been through any optimisation pass, and in particular, I would like to obtain MIR code that is not aware of any layout choice that could be made by the compiler.

A year ago, there was a query called analysed_mir, that would give you exactly that kind of code, and in particular it would give you MIR:

  • unaware of layout
  • non optimized
  • already analyzed (typeck & borrowck)

It seems that that query is gone. Am I looking in the wrong place?

Ideally, I would prefer to avoid calling this query directly. If possible, I would like to be able to directly write a codegen backend that uses this code instead of optimized_mir.

I'd be willing to write the PRs required for all that to work of course, given some guidance.

Thanks!

3 Likes

It looks like that isn't possible at the moment. I'm trying my best to go around that, but it seems very difficult. One thing I could do is decide on what passes to run, and run them manually. In particular, I would like to avoid the Deaggregation phase of MIR for example.

I tried running writing my own version of mir_drops_elaborated_and_const_checked, which would do the same thing without deaggregation, and adding the RemoveStorageMarker pass, but it doesn't work because most tools to do that are private, and even if they weren't, that would not override the query internally.

Any idea on a PR I could write to the compiler to help me in my task? Otherwise, it looks like I'm just going to use mir_const without borrow checking just because I want to avoid deaggregation...

Discussion moved to Zulip

Can you share the link? I am expecting a solution to this problem at Zulip.

Hi!

Basically the query is mir_const_elaborated_and_drops_checked.

The actual zulip discussion is there but diverged a bit:

1 Like

Thanks for sharing this query and that link. I have learned a lot now.