[LLVMdev] Pass registered multiple times!

Lu Zhao luzhao at cs.utah.edu
Mon Mar 31 13:55:58 PDT 2008


It turned out to be the problem of this line in Makefile

LLVMLIBS = LLVMCore.a LLVMSupport.a LLVMSystem.a

The error is gone when I remove the above line.

However, the pass output only contains one line of the main function.

First: main

It does not have puts and __main as shown in this page:
http://llvm.org/docs/WritingAnLLVMPass.html#running

So I guess the drived FunctionPass only works on the application
functions, not on the library functions of LLVM. Is that right?

Thanks.
Lu

On Mon, 31 Mar 2008 00:47:26 -0600
Lu Zhao <luzhao at cs.utah.edu> wrote:

> Hi,
> 
> I'm writing my first hello world Pass with the class name First, but
> when I tried to load it using opt, I got the following error:
> 
> /var/soft/llvm-2.2-build/lib/Transforms/Hello$ opt
> -load ../../../Debug/lib/First.so --help
> opt: /var/soft/llvm-2.2/lib/VMCore/Pass.cpp:157:
> void<unnamed>::PassRegistrar::RegisterPass(llvm::PassInfo&): Assertion
> `Inserted && "Pass registered multiple times!"' failed. 
> Aborted
> 
> The code is as follows.
> 
> #include "llvm/Pass.h"
> #include "llvm/Function.h"
> 
> using namespace llvm;
> 
> namespace {
>   struct First : public FunctionPass {
>     static char ID;
>     First(): FunctionPass((intptr_t)&ID) {}
> 
>     virtual bool runOnFunction(Function &F)
>     {
>       llvm::cerr << "First: " << F.getName() << "\n";
>       return false;
>     }
>   };
> 
> 
>   char First::ID = 0;
>   RegisterPass<First> X("first", "First world pass");
> }
> 
> and the Makefile:
> 
> LEVEL = ../../..
> LIBRARYNAME = First
> LOADABLE_MODULE = 1
> LLVMLIBS = LLVMCore.a LLVMSupport.a LLVMSystem.a
> include $(LEVEL)/Makefile.common
> 
> Thanks in advance.
> Lu
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list