Intellij / cargo / rust: look @ assembly code of a given function

I want to see the generated assembly code for a particular rust function when compiled with --release.

I am using IntelliJ.

Is GitHub - gnzlbg/cargo-asm: cargo subcommand showing the assembly or llvm-ir generated for Rust code my best solution ?

Alternatively, you can use godbolt if you are willing to go online: using -O in compiler options gives the same output as --release I believe.

Current code involves multiple crates. Is this something I can install locally and just point it at my cargo workspace ?

You can install it locally (there are some instructions on github), but I couldn't make it work with dependencies :frowning:. I think it would be better to use cargo-asm in this case.

@arnaudgolfouse

This is the work flow I converged to:

  1. perf record -e blahblahblah cargo test --release -- blah blah blah

  2. pref report

  3. click on the function taking most time

  4. it shows the assembly code pseud-embedded with the rust src

This doesn't work very well if we want to see the asm for arbitrary rust fns, but as it turns out, in general, we only care about the asm of the ones triggering lots of events.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.