I wrote a few own passes for llvm, in order to use them with clang.
I integrated them in llvm (not dynamically loaded). They are even listed in the Optimizations
The proper way to do this would be to make clang add your pass to the pass manager it builds. See clang/lib/CodeGen/BackendUtil.cpp:void EmitAssemblyHelper::CreatePasses()
for how it's handled for the sanitizers.
You can run your own pass with clang directly with -Xclang.
clang++ -Xclang -load -Xclang ./libmypass.so input.cpp
Source