I scoured the LLVM C API and could not find bindings for the new pass manager beyond LLVMRunPasses(), which Inkwell uses to implement Module::run_passes(), which I use here. (Please check my work)
Pros:
Allows qir-runner to be built with the latest version of LLVM without disturbing LLVM 14 support
Saves y'all effort later when you eventually upgrade LLVM
Cons:
Less type safety (if you typo the name of a pass, you will find out only at runtime)
Creating the TargetMachine is ugly (any ideas?)
Testing
Builds on both LLVM 14.0.6 and 18.1.5
The unit tests (cargo test) pass
If I comment out the call to run_basic_passes_on() and my .ll file contains the following:
Background (Personal Problems)
I generate the QIR I test with qir-runner using LLVM 18, so the LLVM IR contains only opaque pointers. This causes errors like the following:
Building qir-runner with LLVM 18 (which supports only opaque pointers) works great except that qir-runner still uses the legacy pass manager, which was removed in LLVM 17.
This PR
Because the new LLVM pass manager has existed since LLVM 13, it is safe even on y'all's version (LLVM 14) to upgrade to the new pass manager instead of using the legacy pass manager.
I scoured the LLVM C API and could not find bindings for the new pass manager beyond
LLVMRunPasses()
, which Inkwell uses to implementModule::run_passes()
, which I use here. (Please check my work)Pros:
Cons:
Testing
cargo test
) passrun_basic_passes_on()
and my.ll
file contains the following:I get the following error when I run qir-runner:
This indicates that the passes are running when the call is not commented (or at least
strip-dead-prototypes
is)