[llvm-dev] Generalizing LLVM extensions that provide new passes

Serge Guelton via llvm-dev llvm-dev at lists.llvm.org
Fri May 3 10:17:49 PDT 2019


Hi llvm-dev,

I'd like to advertise a modest on-going effort to make it easier for third-party project to build a full llvm toolchain with extra custom passes without 1) relying on loaded passes 2) modifying llvm codebase.

1) Is generally achieved using in-tree developpment, but then you need to add your extra passes in the existing layout, which mixes llvm codebase and third-party codebase thus breaks 2).

There already exist a project that achieves 1) and 2): Polly. Unfortunately, it comes at the price of explicit reference to Polly with Conditional CMake Statements and #ifdef in C++ sources, which is rather specific.

My proposal is to allow projects in tools/ to register themselves as llvm-extension using a cmake variable, which would automatically result in the registration of passes  in clang/opt/bugpoint. This is just a generalization of the Polly approach, Polly providing a nice use-case to validate the approach.

The expected workflow would be:

1. checkout the monorepo
2. checkout third party extensions under tools (or symlink)
3. configure the build with -DLLVM_EXTENSION_LIBS listing the extra projects
4. build

The extension should provide an initialize##Ext##Passes and a Register##Ext##Passes function in the appropriate namespace as entry-point into pass managers, and that's all.

https://reviews.llvm.org/D61446 tries to implement such behavior, I'd be happy to gather any thoughts on the subject.




More information about the llvm-dev mailing list