[LLVMdev] newbie with pass registering Problem
Nicole Irwanto
kesetrum at web.de
Wed Apr 23 02:48:15 PDT 2008
Hi John!!
>1) Have you ensured that your passes have different arguments to the =
>RegisterPass constructor (i.e., they have different names)?
Yes, I only write one Pass (Function Pass) and gave it that one name.
>2) Are you sure that variable X is only being defined once? There are =
>some ways in which you could have unintentionally defined it twice. For =
>example, if you put the RegisterPass line in a header file that is =
>included by multiple source files in your pass's source code, it will be =
>defined multiple times, possibly giving rise to this error. In our =
>code, we use RegisterPass inside a single .cpp file to ensure it's only =
>defined once.
Yes, I'm sure. I wrote the Pass and the RegisterPass also in a .cpp file, like this:
#include<vector>
#include"llvm/Pass.h"
#include"llvm/Function.h"
#include"llvm/BasicBlock.h"
#include"llvm/Instruction.h"
#include"../blockNrs/blockNrs.h"
#include"GenomManager.h"
using namespace std;
using namespace llvm;
namespace {
class FunctionAnalysis : public FunctionPass
{
public:
static char ID;
FunctionAnalysis() : FunctionPass((intptr_t)&ID) {} // Konstruktor ruft Funktionsdurchlauf auf
~FunctionAnalysis() {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequired<blockNrs>();
};
virtual bool runOnFunction(Function &F) // F is a pointer to a Function instance
{
GenomManager *GGenomManager;
GGenomManager=new GenomManager();
blockNrs &bnrs=getAnalysis<blockNrs>();
GGenomManager->newFunction(F);
for(Function::iterator b = F.begin(), be = F.end(); b!=be; ++b)
{
//aktuelle Block Nummer wird geholt
blockCounter *bcntr = bnrs.lookup(b);
GGenomManager->newBlock(&(*b),*bcntr);
for(BasicBlock::iterator i = b->begin(), ie = b->end(); i!=ie; ++i)
{
GGenomManager->newInstruction(i);
}// end for BB
} // end for Function
return false;
} // end runOnFunction
private:
};// end class
char FunctionAnalysis::ID = 0;
RegisterPass<FunctionAnalysis> X("gasched", "GA Scheduling Pass");
} // end namespace
Could it be that I did something wrong in the Makefile of the source code? The source code itself is compilable. The Error Message occurred when I tried to test it ("opt -load" its .so file ) .
Thanks a lot...
-Nicole-
_______________________________________________________________________
EINE FÜR ALLE: die kostenlose WEB.DE-Plattform für Freunde und Deine
Homepage mit eigenem Namen. Jetzt starten! http://unddu.de/?kid=kid@mf2
More information about the llvm-dev
mailing list