Error when trying to chain two llvm transform passes

Hi,

I am trying to chain two transform passes.

** The first pass is a function pass which requires the ‘memory dependence pass’ .

** The second pass is a function pass which requires the first pass above.

The passes run fine when executed alone.

I get the following error when I try to run my second pass with the following code added

void getAnalysisUsage(AnalysisUsage &AU)const{
AU.setPreservesCFG();
AU.addRequired<First_Pass>();

}

Assertion failed: (PI && “Expected required passes to be initialized”), function schedulePass, file PassManager.cpp, line 597.

I register the passes using RegisterPass function call. What else should I be doing?

I appreciate your help!!

regards,
Ashwin

Initializing them. Are you using INITIALIZE_PASS_DEPENDENCY, INITIALIZE_AG_DEPENDENCY, etc?

-Krzysztof

Assertion failed: (PI && “Expected required passes to be initialized”),
function schedulePass, file PassManager.cpp, line 597.

I register the passes using RegisterPass function call. What else should
I be doing?

Initializing them. Are you using INITIALIZE_PASS_DEPENDENCY, INITIALIZE_AG_DEPENDENCY, etc?

No. I am not sure how they work . I am trying to use the INITIALIZE_PASS macro. I get the following error

error: definition or redeclaration of ‘initializeMyPassNamePass’ not in a namespace enclosing 'llvm’

should i add the passname to a header file ? if so where?

Thank you!!

-Krzysztof


Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation


LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

regards,
Ashwin

The easiest way is to "cheat" and see how existing code does it. :slight_smile:

Take, dead store elimination, for example:

In DeadStoreElimination.cpp, there is

     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.setPreservesCFG();
       AU.addRequired<DominatorTree>();
       AU.addRequired<AliasAnalysis>();
       AU.addRequired<MemoryDependenceAnalysis>();
       AU.addPreserved<AliasAnalysis>();
       AU.addPreserved<DominatorTree>();
       AU.addPreserved<MemoryDependenceAnalysis>();
     }

and

INITIALIZE_PASS_BEGIN(DSE, "dse", "Dead Store Elimination", false, false)
INITIALIZE_PASS_DEPENDENCY(DominatorTree)
INITIALIZE_PASS_DEPENDENCY(MemoryDependenceAnalysis)
INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
INITIALIZE_PASS_END(DSE, "dse", "Dead Store Elimination", false, false)

The macros will generate a function called "initializeDSEPass".

Now, in the same file, in the constructor, there is a call to it:
     DSE() : FunctionPass(ID), AA(0), MD(0), DT(0) {
       initializeDSEPass(*PassRegistry::getPassRegistry());
     }

Now you can grep the sources to see if the "initializeDSEPass" is in any header. In my source tree, it's in:

include/llvm/InitializePasses.h
lib/Transforms/Scalar/DeadStoreElimination.cpp
lib/Transforms/Scalar/Scalar.cpp

In InitializePasses.h there is a namespace "llvm" with all the initialization functions listed in it. For a particular pass, the other occurrences may differ slightly, but this is the core of what you need.

You don't really need to use RegisterPass. I only found two places that use it and they both are in the code generation.

-Krzysztof