I have written a custom function pass with the new pass manager (it inserts dynamic watermarks in IR Code). I’d like to test if the functionality of llvm is in some way disturbed if the watermark is inserted and therefore would like to test the patched optimization pipeline on the test suite. Currently the pass is only run in opt and only if opt receives its flag. Is there a way to either
- persuade LIT to always call opt with the flag for my pass
- patch opt s.t. my pass is always run no matter if the flag is present or not
For registering of the pass i followed the Tutorial for writing pass in the new pass manager and the example “Bye”.
Thank you very much!
Have you seen Using the New Pass Manager — LLVM 18.0.0git documentation?
For example, the
Bye plugin calls
PB.registerVectorizerStartEPCallback() which does this.
I did exactly that, i created a cpp file in which i added the pass with the
registerVectorizerStartEPCallback and the
registerPipelineParsingCallback (the pass itself is defined in a header only file which is included in the cpp file), i build the cpp file with the cmake function
add_llvm_pass_plugin, which afaik only builds the .so file (the llvm binaries don’t link with it, only the other way around), so i added my pass additionally in the PassRegistry (and included my header in the PassBuilder).
Nevertheless i need to explicitly include the flag for opt to run my pass.
opt -load-pass-plugin loads a shared library plugin, I assume that’s what you’re doing. If you run one of the default optimization pipelines like
opt -O3 it should automatically run all the
register*EPCallback() passes, like your pass.
If you register everything via
registerPipelineParsingCallback, you don’t need to also add it to
What exactly is the
opt command you’re running?
That works alright, but again the register passes are only run if i dynamically include the plugin, which i cant if opt is run by llvm-lit, this is why i also included it statically, but even then a flag is needed to include it. Is there a way to modify the behaviour of the registration in
PassRegistry.def, s.t. a pass is always added to a default pipeline?
I originally understood your original comment to mean you were running the (not super well named) test-suite Guide — LLVM 18.0.0git documentation where you can specify extra compile arguments via CMake flags, but now I realize you probably mean
check-llvm. Not sure why you’d want to unconditionally run your pass over that since it’ll change behavior in ways the tests don’t expect.
If you’re not using a plugin, you’d need to manually change the optimization pipelines in