[llvm-dev] How to debug passes

Iulia Stirb via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 30 10:59:58 PDT 2019


Hi Lorenzo,
Sorry for the late answer.
I am loading LLVMHello.so in the command, but, as I was explaining to Andrzej in the previous mail, I copy pasted in the mail another command, from the source article, which uses dummypass. I also registered the Hello pass. There is no error or warning when executing the opt load command, but it seems like it is doing some processing (maybe in infinite loop) because the command does not finish execution. It is strange though that the command is not displaying nothing, even though there is a print at the very beginning of the runOnModule function.
This is the structure of my pass:
class Hello : public ModulePass {public: static char ID;  Hello() : ModulePass(ID) { }
 bool runOnModule(Module &M) override;
 void getAnalysisUsage(AnalysisUsage &AU) const override { getAnalysisUsage(AU); }
...

static RegisterPass<Hello> X("hello", "Hello World Pass", false /* Only looks at CFG */, false /* Analysis Pass */);
static RegisterStandardPasses Y( PassManagerBuilder::EP_EarlyAsPossible, [](const PassManagerBuilder &Builder, legacy::PassManagerBase &PM) { PM.add(new Hello()); });
...
bool Hello::runOnModule(Module &M) { errs() << "Start pass: ";

Could you please help with any ideas?
Thank you.Kind regards,Iulia Stirb

 

    On Thursday, September 19, 2019, 12:32:06 AM GMT+3, Lorenzo Casalino <lorenzo.casalino93 at gmail.com> wrote:  
 
  
    opt -load lib­dum­my­pass.so -dum­my­pass hel­lo.ll
     
 
   
Looks like you are loading a shared library different from "LLVMHello.so".
 
did you change the name of the compilation unit from "Hello.cpp" into
 "dummypass.cpp"?
 
 

 
 
(As asked previously by Andrzej) did you register the dummy pass?
 
> RegisterPass<DummyPass> X("dummypass", "whatever");
 

 
 
Is any error/warning triggered when loading the library, executing "opt" or
 during compilation?
 
 

 
 
Could you attach the fragment containing the "DummyPass"?
 
 

 
 
Lorenzo

    
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190930/7907809a/attachment.html>


More information about the llvm-dev mailing list