Thanks John,<br><br>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.<br><br>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.<br>
<br>Thanks again,<br><br>Juan Carlos<br><br><br><div class="gmail_quote">On Tue, Dec 15, 2009 at 4:13 PM, John Criswell <span dir="ltr"><<a href="mailto:criswell@cs.uiuc.edu">criswell@cs.uiuc.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">Juan Carlos Martinez Santos wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello LLVM,<br>
<br>
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:<br>
<br>
***@ubuntu:~/test$ opt -load ../../llvm/Debug/lib/MyPass.so -mypass < hello.bc > /dev/null<br>
opt: Pass.cpp:159: void<unnamed>::PassRegistrar::RegisterPass(const llvm::PassInfo&): Assertion `Inserted && "Pass registered multiple times!"' failed.<br>
Aborted<br>
</blockquote></div>
I don't see any obvious problems with your source code.<br>
<br>
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.<br>

<br>
An easy way to test this is to run opt --help-hidden and see if "mypass" is in the list.<br>
<br>
-- John T.<div><div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
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?<br>
<br>
Thanks in advance,<br>
<br>
 Juan Carlos<br>
<br>
*****************<br>
*** Makefile ***<br>
*****************<br>
LEVEL = ../../..<br>
LIBRARYNAME = MyPass<br>
LOADABLE_MODULE = 1<br>
LLVMLIBS = LLVMCore.a LLVMSupport.a LLVMSystem.a<br>
include $(LEVEL)/Makefile.common<br>
<br>
**********************<br>
*** MyPass.cpp ***<br>
**********************<br>
#include "llvm/Pass.h"<br>
#include "llvm/Function.h"<br>
#include "llvm/Support/raw_ostream.h"<br>
<br>
using namespace llvm;<br>
<br>
namespace {<br>
struct MyPass : public FunctionPass {<br>
<br>
    static char ID;<br>
        MyPass() : FunctionPass(&ID) {}<br>
<br>
         virtual bool runOnFunction(Function &F) {<br>
           errs() << "MyPass: " << F.getName() << "\n";<br>
           return false;<br>
         }<br>
       };  // end of struct MyPass<br>
<br>
char MyPass::ID = 0;<br>
RegisterPass<MyPass> X("mypass", "My first Pass",<br>
                      false /* Only looks at CFG */,<br>
                      false /* Analysis Pass */);<br>
}  // end of anonymous namespace<br>
<br>
<br>
-- <br>
Juan Carlos<br>
</blockquote>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Juan Carlos<br>