[LLVMdev] Problems with written function pass

Marc Stöttinger id999 at gmx.de
Mon Sep 22 12:16:10 PDT 2008


Hello,
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/ 
MParSchedule.so  --load /work0/llvm-2.2/Debug/lib/LLVMblockNrs.so  -- 
load /work0/llvm-2.2/Debug/lib/Genome.so --load /work0/llvm-2.2/Debug/ 
lib/GA_VHDL_Pass.so -GA_VHDL_Pass -mem2reg -verify -f -o opt.o a.out.bc
opt: Pass.cpp:157: void<unnamed>::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 {
         private:
                 GenomePass* GP;
                 Genome* fitG;
         public:
                 static char ID; // Pass identification, replacement  
for typeid
                 GA_VHDL_Pass() : FunctionPass((intptr_t)&ID) {}
                 virtual bool runOnFunction(Function &F) {
                         GP = &getAnalysis<GenomePass>();
                         fitG=GP->lookup(&F);
                         std::cerr<<"test"<<endl;

                         return false;
                 }

                 virtual void getAnalysisUsage(AnalysisUsage &AU)  
const {
                         AU.addRequired<GenomePass>();
                 };
         };


         char GA_VHDL_Pass::ID = 0;
}
namespace{
         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
#

opt.o.ll: opt.o
         /work0/llvm-2.2/$(RELEASE)/bin/llvm-dis -o opt.o.ll opt.o

opt.o: a.out.bc
         /work0/llvm-2.2/$(RELEASE)/bin/opt  --load /work0/llvm-2.2/$ 
(RELEASE)/lib/MParSchedule.so  --load /work0/llvm-2.2/$(RELEASE)/lib/ 
LLVMblockNrs.so  --load /work0/llvm-2.2/$(RELEASE)/lib/Genome.so -- 
load /work0/llvm-2.2/$(RELEASE)/lib/GA_VHDL_Pass.so -GA_VHDL_Pass - 
mem2reg -verify -f -o opt.o a.out.bc

a.out.bc: testpass.c
         /work0/llvm-gcc/install/bin/llvm-gcc -c -emit-llvm  
testpass.c -o a.out.bc
clean:
         rm  a.out.bc  opt.o opt.o.ll

Thanks for your help,
Marc




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080922/27cc3a36/attachment.html>


More information about the llvm-dev mailing list