llc undefined symbol

Hi all

I’m writing a pass for the llc tool. If I try to load my pass(llc -load …/, this error message appears :

Error opening ‘/nfs/wsi/ti/graumann/llvm-2.5/Release/lib/’: /nfs/wsi/ti/graumann/llvm-2.5/Release/lib/ undefined symbol: _ZTVN12_GLOBAL__N_119MyRegisterAllocatorE

-load request ignored.

Is this code wrong for the pass registration, or the makefile?

Thank you for help


Code of my pass:

using namespace llvm;

namespace {

struct MyRegisterAllocator : public MachineFunctionPass {

static char ID; // Pass identification, replacement for typeid

MyRegisterAllocator() : MachineFunctionPass(&ID) {}

virtual bool runOnMachineFunction(MachineFunction &MF);


char MyRegisterAllocator::ID = 0;


static RegisterPassX(“myregalloc”,

" my register allocator help string");

FunctionPass* createMyRegisterAllocator() {

return new MyRegisterAllocator();


static RegisterRegAlloc MyRegAlloc(“myregalloc”,

" my register allocator help string",


the makefile:

LEVEL = …/…/…




#LLVMLIBS = LLVMCore.a LLVMSupport.a LLVMSystem.a

LINK_COMPONENTS = support system

include $(LEVEL)/Makefile.common

You have to define (instantiate) all your virtual functions. runOnMachineFunction is one such function, there may be others as well.

At the moment there are in my pass only this virtual function
(runOnMachineFunction). maybe is there an other reason?

Thank you

Again, best guess since you don't actually include enough information...

You do not have a definition for it. The anonymous namespace of the header doesn't create a single anonymous namespace for the header, rather, it uses the anonymous namespace of the translation unit. Each use of the header creates a different class, completely unrelated to all other classes of the exact same name. Try never defining classes in anonymous namespaces in headers.