Iulia, You need to check the contents of the hello.ll (or hello.bc) file rather than the input *.c file - ultimately that's what opt consumes. Try compiling without any optimisations: clang -O0 -emit-llvm -S hello.c -c -o hello.ll -Andrzej On 18/09/2019 11:34, iulia_s24 wrote:> Hi, > > Actually I copy-pasted step 5 from the article in which I found the > solution, in the text of the mail so that is why dummypass appears > instead of hello. I used hello instead of dummypass in my tries, but it > still doesn't display nothing after recompiling the pass. The hello.c > file contains several functions, so the module pass should display > something (I placed a message at the verry beginning of the runOnModule > funtion of the pass). I am compiling all the code once with ninja on > Linux and I have seen that the hello pass is compiled as well. I have > not compiled it separatelly. > > Do you have any ideas why is this? > > Thank you, > Iulia > > > > Trimis de pe smartphone-ul meu Samsung Galaxy. > > -------- Mesaj original -------- > De la: Andrzej Warzynski <Andrzej.Warzynski at arm.com> > Date: 17.09.2019 10:44 (GMT+02:00) > Către: Iulia Stirb <iulia_s24 at yahoo.com>, via Llvm-dev > <llvm-dev at lists.llvm.org>, nd <nd at arm.com> > Subiect: Re: [llvm-dev] How to debug passes > > Hi Iulia, > > You can skip step 5 - it's not required. opt will happily work with *.ll > as well as *.bc files. Since textual form _is_ much easier to read for > humans, you can generate it directly in step 4: > > clang -O3 -emit-llvm -S hello.c -c -o hello.ll > > Otherwise your steps look correct (assuming that when registering your > pass with RegisterPass<> you used 'dummypass' as the name for your > pass). Did you verify that hello.ll contains any functions? And have you > tried similar steps with the Hello pass? > > -Andrzej > > On 16/09/2019 14:49, Iulia Stirb via llvm-dev wrote: > > Hi, > > > > Could you please confirm the following steps for debugging a pass? > > > > 1. copy your pass into llvm/lib/Transforms/Hello/Hello.cpp > > > > 2. name you pass Hello > > > > 3. insert debug messages like:| > > | > > | > > | > > | errs() << "Visiting function " << F.getName();| > > | > > | > > ||4. get LLVM bitcode: > > | > > > > clang -O3 -emit-llvm hello.c -c -o hello.bc > > > > | > > > > |5. disassemble the bitcode: > > > > | llvm-dis hello.bc| > > > > 6. |run the pass on your program: > > > > opt -load libdummypass.so -dummypass hello.ll| > > | > > > > > > The above steps did not work because the last step does not display any > > error message that has been added in the pass. > > > > Could you please help to debug the pass by displaying the error messages? > > > > Thank you. > > Kind regards, > > Iulia > > > > > > > > > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > > IMPORTANT NOTICE: The contents of this email and any attachments are > confidential and may also be privileged. If you are not the intended > recipient, please notify the sender immediately and do not disclose the > contents to any other person, use it for any purpose, or store or copy > the information in any medium. Thank you.IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Hi, I checked the content of the hello.ll file and I have the bitcode disassembled in it. Compiling without optimizations gives the same result. Regards, Iulia On Wednesday, September 18, 2019, 5:58:41 PM GMT+3, Andrzej Warzynski <Andrzej.Warzynski at arm.com> wrote: Iulia, You need to check the contents of the hello.ll (or hello.bc) file rather than the input *.c file - ultimately that's what opt consumes. Try compiling without any optimisations: clang -O0 -emit-llvm -S hello.c -c -o hello.ll -Andrzej On 18/09/2019 11:34, iulia_s24 wrote:> Hi, > > Actually I copy-pasted step 5 from the article in which I found the > solution, in the text of the mail so that is why dummypass appears > instead of hello. I used hello instead of dummypass in my tries, but it > still doesn't display nothing after recompiling the pass. The hello.c > file contains several functions, so the module pass should display > something (I placed a message at the verry beginning of the runOnModule > funtion of the pass). I am compiling all the code once with ninja on > Linux and I have seen that the hello pass is compiled as well. I have > not compiled it separatelly. > > Do you have any ideas why is this? > > Thank you, > Iulia > > > > Trimis de pe smartphone-ul meu Samsung Galaxy. > > -------- Mesaj original -------- > De la: Andrzej Warzynski <Andrzej.Warzynski at arm.com> > Date: 17.09.2019 10:44 (GMT+02:00) > Către: Iulia Stirb <iulia_s24 at yahoo.com>, via Llvm-dev > <llvm-dev at lists.llvm.org>, nd <nd at arm.com> > Subiect: Re: [llvm-dev] How to debug passes > > Hi Iulia, > > You can skip step 5 - it's not required. opt will happily work with *.ll > as well as *.bc files. Since textual form _is_ much easier to read for > humans, you can generate it directly in step 4: > > clang -O3 -emit-llvm -S hello.c -c -o hello.ll > > Otherwise your steps look correct (assuming that when registering your > pass with RegisterPass<> you used 'dummypass' as the name for your > pass). Did you verify that hello.ll contains any functions? And have you > tried similar steps with the Hello pass? > > -Andrzej > > On 16/09/2019 14:49, Iulia Stirb via llvm-dev wrote: > > Hi, > > > > Could you please confirm the following steps for debugging a pass? > > > > 1. copy your pass into llvm/lib/Transforms/Hello/Hello.cpp > > > > 2. name you pass Hello > > > > 3. insert debug messages like:| > > | > > | > > | > > | errs() << "Visiting function " << F.getName();| > > | > > | > > ||4. get LLVM bitcode: > > | > > > > clang -O3 -emit-llvm hello.c -c -o hello.bc > > > > | > > > > |5. disassemble the bitcode: > > > > | llvm-dis hello.bc| > > > > 6. |run the pass on your program: > > > > opt -load libdummypass.so -dummypass hello.ll| > > | > > > > > > The above steps did not work because the last step does not display any > > error message that has been added in the pass. > > > > Could you please help to debug the pass by displaying the error messages? > > > > Thank you. > > Kind regards, > > Iulia > > > > > > > > > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > > IMPORTANT NOTICE: The contents of this email and any attachments are > confidential and may also be privileged. If you are not the intended > recipient, please notify the sender immediately and do not disclose the > contents to any other person, use it for any purpose, or store or copy > the information in any medium. Thank you.IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190918/ca034a6b/attachment.html>
> opt -load libdummypass.so -dummypass hello.llLooks 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/20190918/1d8261ca/attachment.html>