[LLVMdev] Pass registered multiple times!

Lu Zhao luzhao at cs.utah.edu
Sun Mar 30 23:47:26 PDT 2008


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



More information about the llvm-dev mailing list