I am following the document “Writing an LLVM Pass”. When I ran “opt -load …/…/…/Debug/lib/MyPass.so -mypass < hello.bc > /dev/null” I got the next error:
***@ubuntu:~/test$ opt -load …/…/llvm/Debug/lib/MyPass.so -mypass < hello.bc > /dev/null
opt: Pass.cpp:159: void::PassRegistrar::RegisterPass(const llvm::PassInfo&): Assertion `Inserted && “Pass registered multiple times!”’ failed.
To compile MyPass I used “make” command instead of “gmake”, could it be the problem? Or maybe I just type (copy) something wrong? Could someone take a look of my files and point my errors out?
Thanks in advance,
Juan Carlos Martinez Santos wrote:
I am following the document "Writing an LLVM Pass". When I ran "opt -load ../../../Debug/lib/MyPass.so -mypass < hello.bc > /dev/null" I got the next error:
***@ubuntu:~/test$ opt -load ../../llvm/Debug/lib/MyPass.so -mypass < hello.bc > /dev/null
opt: Pass.cpp:159: void<unnamed>::PassRegistrar::RegisterPass(const llvm::PassInfo&): Assertion `Inserted && "Pass registered multiple times!"' failed.
I don't see any obvious problems with your source code.
Are you compiling this file as part of your own project, or did you add it to your LLVM source tree (e.g., placing MyPass.cpp into lib/Transforms in the LLVM source tree)? If you did the latter, it's possible that your pass is being compiled into the opt program automatically by the LLVM build system, and so when you do a -load of your dynamic library, you get your pass defined twice.
An easy way to test this is to run opt --help-hidden and see if "mypass" is in the list.
-- John T.
I was just following the instructions; I created a new folder inside of llvm (/lib/Trasnforms/MyPass). After I run opt --help-hidden, I didn’t see mypass.
However, I found that if I remove the LLVMLIBS (LLVMCore.a LLVMSupport.a LLVMSystem.a) from the Makefile, the pass works. I found that after comparing Hello folder (llvm tree) with the information in the website. Now, it is working as I expected.