26

Allow loading LLVM plugins with both legacy and new pass manager by eskarn · Pu...

 2 years ago
source link: https://github.com/rust-lang/rust/pull/91125
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

eskarn commented on Nov 22, 2021

Opening a draft PR to get feedback and start discussion on this feature. There is already a codegen option passes which allow giving a list of LLVM pass names, however we currently can't use a LLVM pass plugin (as described here : https://llvm.org/docs/WritingAnLLVMPass.html), the only available passes are the LLVM built-in ones.

The proposed modification would be to add another codegen option pass-plugins, which can be set with a list of paths to shared library files. These libraries are loaded using the LLVM function PassPlugin::Load, which calls the expected symbol lvmGetPassPluginInfo, and register the pipeline parsing and optimization callbacks.

An example usage with a single plugin and 3 passes would look like this in the .cargo/config:

rustflags = [
    "-C", "pass-plugins=/tmp/libLLVMPassPlugin",
    "-C", "passes=pass1 pass2 pass3",
]

This would give the same functionality as the opt LLVM tool directly integrated in rust build system.

Additionally, we can also not specify the passes option, and use a plugin which inserts passes in the optimization pipeline, as one could do using clang.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK