[LLVMdev] initializeNAMEPass(llvm::PassRegistry&) should have been declared inside 'llvm'

Griffin Wright grwright at umich.edu
Mon Jan 30 13:06:01 PST 2012


Hey all,

So I've been working to fix a problem I had wherein I could not properly
initialize AliasAnalysis profiling information.  In order to fix it, I've
had to rewrite how my pass operates, such that it contains this in the
FunctionPass declaration;

  RelRecovery() : FunctionPass(ID) {
        llvm::initializeRelRecoveryPass(*PassRegistry::getPassRegistry());
  }

and contains these macros

INITIALIZE_PASS_BEGIN(RelRecovery, "relRecovery", "...", false, false)
INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
INITIALIZE_PASS_END(RelRecovery, "relRecovery", "Reliability transformation
for lightweight recovery", false, false)

However, as my pass is external the rest of llvm (and is compiled
separately from the main llvm source), I am having trouble getting this to
work.  I was told to also modify include/llvm/LinkAllPasses.h to add a call
to (void) llvm::createRelRecoveryPass(); which I have done, but when I go
to my main llvm-obj directory to build llvm so that the call is valid when
I actually compile my pass files, I get:

/x/grwright/llvm/llvm-obj/tools/opt/Debug+Asserts/opt.o: In function
`ForcePassLinking':
/x/grwright/llvm/llvm-2.9/include/llvm/LinkAllPasses.h:152: undefined
reference to `llvm::createRelRecoveryPass()'

So how do I fix that?  Where do I need to be defining this?

In addition, when I try to just compile the source files for my pass, I
get:

llvm[0]: Compiling RelDepInfo.cpp for Debug+Asserts build (PIC)
In file included from
/x/grwright/llvm/llvm-sfi/RelRecovery/include/RelRecovery.h:20,
                 from RelDepInfo.cpp:1:
/x/grwright/llvm/llvm-2.9/include/llvm/LinkAllPasses.h: In constructor
‘<unnamed>::ForcePassLinking::ForcePassLinking()’:
/x/grwright/llvm/llvm-2.9/include/llvm/LinkAllPasses.h:152: error:
‘createRelRecoveryPass’ is not a member of ‘llvm’
In file included from RelDepInfo.cpp:1:
/x/grwright/llvm/llvm-sfi/RelRecovery/include/RelRecovery.h: In constructor
‘RelRecovery::RelRecovery()’:
/x/grwright/llvm/llvm-sfi/RelRecovery/include/RelRecovery.h:71: error:
‘initializeRelRecoveryPass’ is not a member of ‘llvm’
/x/grwright/llvm/llvm-sfi/RelRecovery/include/RelRecovery.h: At global
scope:
/x/grwright/llvm/llvm-sfi/RelRecovery/include/RelRecovery.h:453: error:
‘void llvm::initializeRelRecoveryPass(llvm::PassRegistry&)’ should have
been declared inside ‘llvm’

I'm sure some of those are related to the initial error from the llvm-obj
build, but does anyone know how I might magically fix all of these bugs in
one go? Or is there another way to set up my pass such that it runs
external to llvm but can still properly its AliasAnalysis stuff?  See my
three emails from last week on the topic.

Thanks,
Griffin



More information about the llvm-dev mailing list