llvm / llvm/llvm-project

LLVM C API does not register statically linked pass plugins

Open
#196,750 1 comment 0 reactions 0 assignees View on GitHub
new issue
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

`LLVMRunPasses` and `LLVMRunPassesOnFunction` create a local `PassBuilder`, but
they do not register statically linked pass plugin callbacks from
`llvm/Support/Extension.def`.

This means a pass plugin linked into tools with `LLVM__LINK_INTO_TOOLS=ON` can be available to `opt` and LTO, but unavailable through the LLVM C API pass builder entry points.

For example, with the `Bye` example plugin linked into tools, this works through `opt`:

```sh
opt -passes=goodbye input.ll -disable-output
```

but the equivalent C API call fails to parse the plugin pass:

```c
LLVMRunPassesOnFunction(F, "goodbye", TM, Options);
```

or, for a module pipeline:

```c
LLVMRunPasses(M, "function(goodbye)", TM, Options);
```

## Expected behavior

`LLVMRunPasses` and `LLVMRunPassesOnFunction` should honor statically linked pass plugins in the same way as `opt` and LTO.

## Actual behavior:

The C API `PassBuilder` does not register the callbacks from `Extension.def`, so passes provided only by statically linked plugins are not recognized.

Contributor guide

Open the contributing guide

Research direction

Start at the LLVMRunPasses and LLVMRunPassesOnFunction C API entry points and compare their local PassBuilder setup with the registration used by opt and LTO. Inspect llvm/Support/Extension.def and the Bye plugin example, then reproduce the failure with the shown opt and C API pipelines. Done means statically linked plugin passes such as goodbye are recognized through both C API entry points.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
api, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.