#[plugin]Expand description
Attribute macro for defining an LLVM plugin.
This macro generates the llvmGetPassPluginInfo entry point required for
LLVM to load the plugin. The annotated function receives a
PassBuilder and should register callbacks
for pipeline parsing, analysis registration, or extension points.
§Parameters
name: The plugin name (string literal).version: The plugin version (string literal).
§Warning
This macro should be used on cdylib crates only. Since it generates
an exported symbol, it should be used once per dylib.
§Example
ⓘ
#[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
}
});
}