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

David Gardner daveg at xmos.com
Wed Dec 14 07:09:07 PST 2011


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;



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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111214/71b7e1ee/attachment.sig>


More information about the llvm-dev mailing list