Problems with written function pass

my name is Marc. I wrote a llvm function pass by using the “hello world” tutorial. But this selfwritten pass (GA_VHDL_Pass) dependes on another function pass (GenomePass). GenomePass also dependes on two other function passes. The Pass GenomePass generates an object, which is used in my GA-VHDL_Pass.

When I compile my Make file I always get this error message:

/work0/llvm-2.2/Debug/bin/opt --load /work0/llvm-2.2/Debug/lib/ --load /work0/llvm-2.2/Debug/lib/ --load /work0/llvm-2.2/Debug/lib/ --load /work0/llvm-2.2/Debug/lib/ -GA_VHDL_Pass -mem2reg -verify -f -o opt.o a.out.bc
opt: Pass.cpp:157: void::PassRegistrar::RegisterPass(llvm::PassInfo&): Assertion `Inserted && “Pass registered multiple times!”’ failed.
make: *** [opt.o] Aborted

I do not find the problem causing this, so perhaps some of you know the problem and a good solution.

Here is the written Code of GA_VHDL_Pass:

//#include “llvm/Pass.h”
//#include “llvm/Function.h”
#include “…/…/Analysis/genome/GenomePass.cpp”

using namespace llvm;

namespace llvm{
class GA_VHDL_Pass: public FunctionPass {
GenomePass* GP;
Genome* fitG;
static char ID; // Pass identification, replacement for typeid
GA_VHDL_Pass() : FunctionPass((intptr_t)&ID) {}
virtual bool runOnFunction(Function &F) {
GP = &getAnalysis();

return false;

virtual void getAnalysisUsage(AnalysisUsage &AU) const {

char GA_VHDL_Pass::ID = 0;
RegisterPass<GA_VHDL_Pass> X(“GA_VHDL_Pass”, “Create VHDL-Code out of a genome”,false);

Followed by the Makefile:

RELEASE=$(shell /work0/llvm-2.2/Debug/bin/llvm-config --build-mode)
.PHONY: opt_out
.PHONY: opt.o.ll
#.PHONY: opte
.PHONY: opt.o

#opt_run:opt.o.s opt.o.ll
opt_run: opt opt.o.ll cat opt.o.ll

Hi Marc,

void<unnamed>::PassRegistrar::RegisterPass(llvm::PassInfo&): Assertion
`Inserted && "Pass registered multiple times!"' failed.

This means you register your pass twice, ie you have the RegisterPass variable
in more than one compile unit.

#include "../../Analysis/genome/GenomePass.cpp"

You shouldn't do this, assuming that GenomePass.cpp contains the
implementation for GenomePass, you will get it (and the associated
RegisterPass) compiled twice.

Instead, seperate your GenomePass.cpp into a .h file in the include/
directory, which contains the class declaration and a .cpp file which contains
method implementations and the RegisterPass variable. Then include the .h
file, including a .cpp file is almost always an error.



Hi Marc, I think this problem came up before, but
I don't recall the solution. Try searching the
mailing list archives.

Best wishes,