I was able to create a pass following . Now goal is amend the pass and try to dump the call graph. I think I have properly amended the source extending my pass from CallGraphSCCPass but unfortunately every time I run it, it crashes. I tried with llvm-6 and llvm-7. I notice that if I change EP_EarlyAsPossible to anything else it does not crash but I don’t see the expected string printed by the runOnSCC.
Could you help me to solve this problem? How should I create the pass?
Thanks for your time
There’s two things going on here:
Firstly, extension points interact in a slightly odd way with optimization levels:
so when you’re not seeing the crash it’s because you’re using an optimization level (probably -O0 because that’s
the default) where the extension point you’re using isn’t used.
Secondly, CGSCC passes can only be added to a GCSCC pass manager. If you use a debug build of clang then the
crash becomes an assertion failure which (somewhat) tells you this:
CallGraphSCCPass.cpp:575: virtual void llvm::CallGraphSCCPass::assignPassManager(llvm::PMStack&, llvm::PassManagerType): Assertion `!PMS.empty() && “Unable to handle Call Graph Pass”’ failed.
From some experimentation it looks like it’s only EP_EarlyAsPossible where we get this error, because (looking
at PassManagerBuilder::populateFunctionPassManager) that extension point uses a Function Pass Manager
whereas all the others look like they use a Module Pass Manager.
All clear now. Is it worthy to open a bug issue?