[llvm-dev] How to debug passes
Andrzej Warzynski via llvm-dev
llvm-dev at lists.llvm.org
Wed Oct 2 00:49:39 PDT 2019
Hi Iulia,
This is really weird - the Hello pass from LLVM definitely works (I run
it occasionally for reference).
"Infinite loop" might mean that you're missing an argument - opt will
wait indefinitely until all positional argument are specified (i.e. the
*.ll file to process). I might be wrong here - that's just my experience
with opt.
Let's take a step back and focus on LLVMHello.so - could you send the
following:
1. Your input *.c (well, just copy and paste the contents here)
2. The command that you use to generate the *.ll file
3. The command that you use to run the Hello pass
4. The command that you used to build LLVM (in particular, LLVMHello.so)
Cheers,
Andrzej
On 30/09/2019 18:59, Iulia Stirb wrote:
> 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:
>
> classHello: publicModulePass{
> public:
> staticcharID;
> Hello() : ModulePass(ID) {
> }
>
> boolrunOnModule(Module &M) override;
>
> voidgetAnalysisUsage(AnalysisUsage &AU) constoverride{
> getAnalysisUsage(AU);
> }
>
> ...
>
> staticRegisterPass<Hello>X("hello", "Hello World Pass",
> false/* Only looks at CFG */,
> false/* Analysis Pass */);
>
> staticRegisterStandardPasses Y(
> PassManagerBuilder::EP_EarlyAsPossible,
> [](constPassManagerBuilder &Builder,
> legacy::PassManagerBase &PM) { PM.add(newHello()); });
>
> ...
>
> boolHello::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 libdummypass.so -dummypass hello.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
>
>
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