Skip to main content

Module plugin

Module plugin 

Source
Expand description

Plugin API for creating LLVM pass plugins.

This module provides types for building LLVM plugins that can be loaded by opt, clang, or other LLVM tools via --load-pass-plugin.

§Usage

Create a cdylib crate and use the plugin attribute macro:

ⓘ
#[llvm_pm::plugin(name = "my_plugin", version = "0.1")]
fn plugin_registrar(builder: &mut llvm_pm::plugin::PassBuilder) {
    builder.add_module_pipeline_parsing_callback(|name, mpm| {
        if name == "my-pass" {
            mpm.add_pass(MyPass);
            llvm_pm::plugin::PipelineParsing::Parsed
        } else {
            llvm_pm::plugin::PipelineParsing::NotParsed
        }
    });
}

Structs§

PassBuilder
Handle to LLVM’s PassBuilder, received by plugin registrar functions.
PassPluginLibraryInfo
Information returned by llvmGetPassPluginInfo.
PluginFunctionPassManager
A borrowed function pass manager received in plugin pipeline parsing callbacks.
PluginModulePassManager
A borrowed module pass manager received in plugin pipeline parsing callbacks.

Enums§

PipelineParsing
Enum describing whether a pipeline parsing callback successfully parsed its given pipeline element.

Functions§

plugin_api_version
Return the LLVM plugin API version.

Attribute Macros§

plugin
Attribute macro for defining an LLVM plugin.