[LLVMdev] Adding an object to llc (analysis pass)

Silken Tiger st at iss.tu-darmstadt.de
Tue May 30 09:22:45 PDT 2006

> One would expect this, its a facility of the C++ language. The anonymous
> namespace is, essentially, the same as declaring everything in it
> static. That is, the symbols are not exported and not available for
> linking.
Yes, it was pretty clear after finding out that this isn't a linking error 
which i suspected...
> > So for all those trying to add an analysis path:
> > * add the object name to the USEDLIBS variable in the tools/llc/Makefile
> > * use the llvm namespace instead of anonyous
> These statements are only true if you're adding an analysis pass to
> LLVM. If the pass is for use outside of LLVM then you want to:
Yes, but this is already documented on the Website and works really well :-).

> > This mail is intended as references for people using the search engines,
> > prior to asking questions :-). But maybe this information could also be
> > added to http://llvm.org/docs/WritingAnLLVMPass.html?
> Such a patch would be readily accepted.
Ok, if i get my pass flying i'll write s.t. unfortunatly i hit another 

Everthing now compiles fine, but when running llc with invoking my own backend 
derived from the cbackend i get the following error:

llc -f -march my_backend a.out.bc
llc: PassManagerT.h:387: void llvm::PassManagerT<Trait>::markPassUsed(const 
llvm::PassInfo*, llvm::Pass*) [with Trait = llvm::MTraits]: Assertion 
`getAnalysisOrNullUp(P) && 
dynamic_cast<ImmutablePass*>(getAnalysisOrNullUp(P)) && "Pass available but 
not found! " "Perhaps this is a module pass requiring a function pass?"' 
llc((anonymous namespace)::PrintStackTrace()+0x1f)[0x880791f]
llc(llvm::PassManagerT<llvm::MTraits>::markPassUsed(llvm::PassInfo const*, 

The requirements of this pass are quite modest:
void MParSchedule::getAnalysisUsage(AnalysisUsage &AU) const {

The Header looks of this pass looks like this:

namespace llvm {
        class MParSchedule : public BasicBlockPass {
                        virtual bool runOnBasicBlock(BasicBlock &B);
                        void getAnalysisUsage(AnalysisUsage &AU) const;
                        virtual void releaseMemory();
                        map<const BasicBlock *,list<Schedule*> *> 
                        list<Schedule*>* lookupBasicBlock(BasicBlock *);
                        bool in_ValueList(Value *val);
                        list<const Value*> ValueList;
                        list<Instruction*> InstructionList;

It gets Registered in the cpp file via:
RegisterAnalysis<MParSchedule> X("MParSchedule","Maximal Parallel Schedule");

This pass has been tested as optimization pass with opt, and everything worked 
in this configuration.


More information about the llvm-dev mailing list