Automatically load LLVM pass regardless of Clang driver mode

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Automatically load LLVM pass regardless of Clang driver mode

Hans Wennborg via cfe-dev
Hello,

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.

Thanks,

Dominic


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatically load LLVM pass regardless of Clang driver mode

Hans Wennborg via cfe-dev
As far as I understand, clang -cc1as does not instantiate a pass
manager, hence a pass plugin would be quite useless. Otherwise,
handling plugin options for -cc1as might just have been forgotten in
cc1as_main.

Michael

Am Di., 4. Feb. 2020 um 16:18 Uhr schrieb Dominic Chen via cfe-dev
<[hidden email]>:

>
> Hello,
>
> 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.
>
> Thanks,
>
> Dominic
>
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev