llvm-mca-macros 0.1.0

Procedural macros for generating `llvm-mca` marker comments
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented2 out of 2 items with examples
  • Size
  • Source code size: 7.35 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 287.93 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 5s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • philipturnbull/llvm-mca
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • philipturnbull

llvm-mca-macros

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

These macros generate markers after the function epilogue and before the function prologue. If more granularity is needed, you can use the llvm-mca crate instead.

Usage

By default, llvm_mca will disable inlining. For example, this:

use llvm_mca_macros::llvm_mca;

#[llvm_mca]
fn quadruple(x: u32) -> u32 {
    let doubled = x + x;
    doubled + doubled
}

will generate the equivalent of:

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

If inlining is desired, the allow_inline attribute can be specified:

use llvm_mca_macros::llvm_mca;

#[llvm_mca(allow_inline)]
fn quadruple(x: u32) -> u32 {
    let doubled = x + x;
    doubled + doubled
}

This will generate the equivalent of:

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

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