[LLVMdev] Running a pass

Juan Carlos Martinez Santos juanc.martinez.santos at gmail.com
Tue Dec 15 13:01:21 PST 2009


Hello LLVM,

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.
Aborted

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

*****************
*** Makefile ***
*****************
LEVEL = ../../..
LIBRARYNAME = MyPass
LOADABLE_MODULE = 1
LLVMLIBS = LLVMCore.a LLVMSupport.a LLVMSystem.a
include $(LEVEL)/Makefile.common

**********************
*** MyPass.cpp ***
**********************
#include "llvm/Pass.h"
#include "llvm/Function.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;

namespace {
struct MyPass : public FunctionPass {

    static char ID;
        MyPass() : FunctionPass(&ID) {}

         virtual bool runOnFunction(Function &F) {
           errs() << "MyPass: " << F.getName() << "\n";
           return false;
         }
       };  // end of struct MyPass

char MyPass::ID = 0;
RegisterPass<MyPass> X("mypass", "My first Pass",
                      false /* Only looks at CFG */,
                      false /* Analysis Pass */);
}  // end of anonymous namespace


-- 
Juan Carlos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091215/ff8248a9/attachment.html>


More information about the llvm-dev mailing list