llvm-mca

Crates.iollvm-mca
lib.rsllvm-mca
version
sourcesrc
created_at2024-11-07 22:52:58.021842
updated_at2024-11-07 22:52:58.021842
descriptionMacros for generating `llvm-mca` marker comments
homepagehttps://github.com/philipturnbull/llvm-mca
repositoryhttps://github.com/philipturnbull/llvm-mca
max_upload_size
id1440399
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Phil Turnbull (philipturnbull)

documentation

README

llvm-mca

Macros to generate marker comments for LLVM's Machine Code Analyzer.

The llvm_mca_begin! and llvm_mca_end! macros will emit LLVM-MCA-BEGIN and LLVM-MCA-END markers, respectively.

If you want to automatically add markers to the beginning and end of a function, you can use the llvm-mca-macros crate instead.

Usage

For example, this:

use llvm_mca::{llvm_mca_begin, llvm_mca_end};

fn quadruple(x: u32) -> u32 {
    llvm_mca_begin!();
    let doubled = x + x;
    llvm_mca_end!();
    doubled + doubled
}

will generate the equivalent of:

fn quadruple(x: u32) -> u32 {
    // emit `LLVM-MCA-BEGIN` marker
    let doubled = x + x;
    // emit `LLVM-MCA-END` marker
    doubled + doubled
}

Naming regions

Regions can also be named. This:

use llvm_mca::{llvm_mca_begin, llvm_mca_end};

fn quadruple(x: u32) -> u32 {
    llvm_mca_begin!("double");
    let doubled = x + x;
    llvm_mca_end!("double");
    doubled + doubled
}

will generated the equivalent of:

fn quadruple(x: u32) -> u32 {
    // emit `LLVM-MCA-BEGIN double` marker
    let doubled = x + x;
    // emit `LLVM-MCA-END double` marker
    doubled + doubled
}

See the Using Markers to Analyze Specific Code Blocks section of the LLVM docs for details about naming regions and how to nest them.

Generating assembly

You must set the RUSTFLAGS="--emit asm" option when building your project with cargo. For example:

RUSTFLAGS="--emit asm" cargo build --release

This will output assembly files in target/*/deps.

Commit count: 1

cargo fmt