[cfe-dev] Automatically load LLVM pass regardless of Clang driver mode

Dominic Chen via cfe-dev cfe-dev at lists.llvm.org
Tue Feb 4 14:17:48 PST 2020


Perhaps this is a silly question, but how do I ensure that a LLVM pass
(implemented as a plugin) is always loaded by Clang, regardless of the
driver mode? Currently, for the old pass manager, I register the pass
using llvm::RegisterPass<> and llvm::RegisterStandardPasses, and for the
new pass manager, llvm::PassPluginLibraryInfo and
PassBuilder.registerPipeline*Callback. At runtime, I'm passing "-Xclang
-load -Xclang <path>" to load the pass, but this doesn't seem to work
for cc1as because those arguments are stripped out. This can break
compilation if I'm also specifying pass-specific arguments using
"-mllvm", because those arguments aren't stripped but become
unrecognized without the pass. I've also tried "-fplugin=" and
"-fpass-plugin=", but they seem to be stripped as well.



More information about the cfe-dev mailing list