[LLVMdev] Adding dependency on MemoryDependenceAnalysis pass to LICM causes opt to get stuck in addPass

Devang Patel dpatel at apple.com
Wed Dec 14 09:50:07 PST 2011


On Dec 14, 2011, at 7:09 AM, David Gardner wrote:

> I'm attempting to add some support for hoisting/sinking of memory-using
> intrinsics in loops, and so I want to use MemoryDependenceAnalysis in
> LICM, but when I modify getAnalysisUsge to include this :
> 
>    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
>      AU.setPreservesCFG();
>      AU.addRequired<DominatorTree>();
>      AU.addRequired<LoopInfo>();
>      AU.addRequiredID(LoopSimplifyID);
>      AU.addRequired<MemoryDependenceAnalysis>();  // <--- added
>      AU.addRequired<AliasAnalysis>();
>      AU.addPreserved<AliasAnalysis>();
>      AU.addPreserved("scalar-evolution");
>      AU.addPreservedID(LoopSimplifyID);
>      AU.addRequired<TargetLibraryInfo>();
>    }
> 
> ..add to the initialize pass list:
> 
> char LICM::ID = 0;
> INITIALIZE_PASS_BEGIN(LICM, "licm", "Loop Invariant Code Motion", false, false)
> INITIALIZE_PASS_DEPENDENCY(DominatorTree)
> INITIALIZE_PASS_DEPENDENCY(LoopInfo)
> INITIALIZE_PASS_DEPENDENCY(LoopSimplify)
> INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo)
> INITIALIZE_PASS_DEPENDENCY(MemoryDependenceAnalysis) // <--- added
> INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
> INITIALIZE_PASS_END(LICM, "licm", "Loop Invariant Code Motion", false, false)
> 
> 
> ..rebuild and then run:
> 
>  gdb --args ~/tmp/checkouts/llvm-build/Debug+Asserts/bin/opt -p -debug -debug-pass=Arguments -basicaa -licm -o /dev/null test.bc
> 
> 
> Then I can see that opt is getting stuck in lib/VMCore/PassManager.cpp
> on the loop at line 672, and just goes round this for as long as I've
> left it for (several minutes) :
> 
>      // Check other pass managers
>      for (SmallVectorImpl<PMDataManager *>::iterator
>           I = IndirectPassManagers.begin(),
>           E = IndirectPassManagers.end(); I != E; ++I)
>        if (Pass *P = (*I)->findAnalysisPass(AID, false))
>          return P;
> 

Do you see a repeated pattern of pass sequence the pass manager is trying to handle ? P->getPassName() is handy.
-
Devang

> This old post on the list :
> http://old.nabble.com/Array-Dependence-Analysis-td16073995.html says
> that "Loop passes can use function passes, but not visaversa." 
> so as far as I can tell this should be OK.
> 
> Am I doing something wrong? (perhaps ordering of the addRequired
> calls or the initialization macros?)
> Is there something else I need to add to allow the memdep pass to be
> required by LICM, or is this a bug?
> 
> 
> 
>  Many thanks,
> 
>    Dave
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list