[llvm-dev] How to debug passes
Andrzej Warzynski via llvm-dev
llvm-dev at lists.llvm.org
Wed Sep 18 07:58:24 PDT 2019
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.
More information about the llvm-dev
mailing list