about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-12-30 02:53:09 +0000
committerbors <bors@rust-lang.org>2021-12-30 02:53:09 +0000
commit1b3a5f29dd9f9ba9de0d501857d4603a54e15707 (patch)
tree6b8341cb67fcb92877c2a02bf9dc68926207f620 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parentd331cb710f0dd969d779510a49a3bafc7f78a54e (diff)
parentf431df0d7f4f56e5c4c6a73023126e1b02104436 (diff)
downloadrust-1b3a5f29dd9f9ba9de0d501857d4603a54e15707.tar.gz
rust-1b3a5f29dd9f9ba9de0d501857d4603a54e15707.zip
Auto merge of #91125 - eskarn:llvm-passes-plugin-support, r=nagisa
Allow loading LLVM plugins with both legacy and new pass manager

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`:

```toml
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.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions