Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Use rustc --emit=llvm-ir,asm main.rs to emit LLVM IR and target assembly from a standalone Rust file. For a Cargo target, use cargo rustc and pass the emit option after --. The output depends on compiler version, target, optimization settings, and other code-generation options, so set those deliberately when comparing results.
Emit LLVM IR and assembly from a standalone Rust file
From the directory containing main.rs, run:
rustc --emit=llvm-ir,asm main.rs
Rustc writes LLVM IR and assembly as separate files. By default, their names are based on the crate name and end in .ll and .s. To choose stable filenames, specify a path for each output:
As an Amazon Associate I earn from qualifying purchases.
rustc --emit=llvm-ir=out.ll,asm=out.s main.rs
The --emit option accepts comma-separated output kinds. Other available kinds include mir for Rust’s Mid-level Intermediate Representation, llvm-bc for LLVM bitcode, obj for a native object file, metadata, and link for the normal linked artifact. These are different stages or artifact types, not interchangeable names for assembly. See the rustc reference for --emit.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Send one text output to the terminal
Rustc can write a text output such as LLVM IR or assembly to standard output by using - as its path:
#1 Best Overall
rustc --emit=llvm-ir=- main.rs
For assembly instead:
rustc --emit=asm=- main.rs
Only one output type can be sent to stdout per invocation. Run separate commands or write both outputs to files if you need both.
Inspect a Cargo package target
Use cargo rustc, select the target you want, and put rustc’s arguments after Cargo’s -- separator. For a binary named my_program:
Rank #2
cargo rustc --bin my_program -- --emit=llvm-ir,asm
For the package library target:
cargo rustc --lib -- --emit=llvm-ir,asm
To compile the binary with Cargo’s release profile:
cargo rustc --release --bin my_program -- --emit=llvm-ir,asm
When a package has multiple targets, specify which one to compile with an option such as --bin or --lib. Cargo forwards the extra rustc arguments to the final compiler invocation for the selected package target, not to its dependencies; as the Cargo cargo rustc reference explains, “The specified args will all be passed to the final compiler invocation, not any of the dependencies.” Cargo may still compile dependencies as part of building the target, but those dependencies do not automatically receive the forwarded emit arguments.
Rank #3
Choose settings that answer your question
Decide whether to inspect unoptimized or optimized output
Rustc’s default optimization level is 0. Use -O for optimization level 3 in a direct rustc invocation:
rustc -O --emit=llvm-ir,asm main.rs
Rustc also documents levels 1, 2, s, and z. In Cargo, --release selects the release profile, whose settings determine the build’s optimization behavior. The rustc code-generation options reference describes the available optimization options.
Optimization can inline, simplify, or remove code, so a function visible in one build may not appear as a distinct function in another. Choose the settings that match your question: an unoptimized build can make some source-to-output relationships easier to follow, while an optimized build shows output after optimization under the selected profile.
Request LLVM IR before LLVM’s usual optimization passes
For a specialized view of IR before LLVM’s usual pre-populated optimization passes, rustc documents this combination:
rustc -O -C no-prepopulate-passes --emit=llvm-ir main.rs
no-prepopulate-passes uses an empty pass list instead of the usual pre-populated list. This is not the same view as ordinary optimized backend output: the command uses -O, but asks LLVM not to run its usual pre-populated passes. Consult the code-generation options reference when interpreting this specialized output.
Account for the target
Assembly is emitted for the selected compilation target. It reflects that target’s instructions and conventions; assembly for one architecture is not a universal listing of what Rust emits. Target CPU and target-feature options can also influence generated code. Rustc’s code-generation options reference documents relevant target and code-generation settings.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Interpret and compare the output carefully
LLVM IR and assembly answer related but distinct questions. LLVM IR shows the representation at LLVM’s level; assembly shows target-specific instructions. Neither is a fixed, target-independent description of a Rust function. Compiler version, target triple, optimization level or Cargo profile, and code-generation flags can all change what appears.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
For a meaningful comparison between two listings, keep the source and these settings the same, and report them alongside the output:
- Rust compiler version: check the installed toolchain with
rustc --version. - Target triple: identify the target for which the output was generated.
- Build profile or optimization level: record whether you used the default,
-O, or a Cargo profile such as release. - Relevant code-generation flags: include CPU, target-feature, or pass-related options that affect the result.
- IR pass context: distinguish ordinary emitted IR from IR requested with
-C no-prepopulate-passes.
Option availability and output details can vary across toolchains. Use rustc --help and rustc -C help to check what your installed compiler supports; the official rustc command-line reference and code-generation options reference document the relevant behavior.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




