David Gardner
2011-Dec-14 15:09 UTC
[LLVMdev] Adding dependency on MemoryDependenceAnalysis pass to LICM causes opt to get stuck in addPass
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>
Devang Patel
2011-Dec-14 17:50 UTC
[LLVMdev] Adding dependency on MemoryDependenceAnalysis pass to LICM causes opt to get stuck in addPass
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
David Gardner
2011-Dec-15 10:31 UTC
[LLVMdev] Adding dependency on MemoryDependenceAnalysis pass to LICM causes opt to get stuck in addPass
> > 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.I do (looking from llvm::PMTopLevelManager::schedulePass with gdb) : Breakpoint 1, llvm::PMTopLevelManager::schedulePass (this=0x1310930, P=0x1310510) at /home/daveg/tmp/checkouts/llvm/lib/VMCore/PassManager.cpp:609 609 P->preparePassManager(activeStack); (gdb) display P->getPassName () [trimmed output for just pass names] 1: P->getPassName () = 0xf0ba95 "Target Library Information" 1: P->getPassName () = 0xf0b6cd "Target Data Layout" 1: P->getPassName () = 0xef3872 "Basic Alias Analysis (stateless AA 1: P->getPassName () = 0xefffe4 "No Alias Analysis (always returns 'may' 1: P->getPassName () = 0xf35a3a "Print module to stderr" 1: P->getPassName () = 0xed58b0 "Loop Invariant Code Motion" 1: P->getPassName () = 0xf00c95 "Dominator Tree Construction" 1: P->getPassName () = 0xefc441 "Natural Loop Information" 1: P->getPassName () = 0xeeb838 "Canonicalize natural loops" 1: P->getPassName () = 0xefc6e2 "Loop Pass Manager" 1: P->getPassName () = 0xefff64 "Memory Dependence Analysis" 1: P->getPassName () = 0xeeb838 "Canonicalize natural loops" 1: P->getPassName () = 0xefc6e2 "Loop Pass Manager" 1: P->getPassName () = 0xefff64 "Memory Dependence Analysis" (repeats those 3 from then on) Removing the `AU.addRequiredID(LoopSimplifyID);' call from the LICM getAnalysisUsage function allows this to work in this case but I expect this is required by the pass in general. Cheers, 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/20111215/7d5f4809/attachment.sig>
Seemingly Similar Threads
- [LLVMdev] Adding dependency on MemoryDependenceAnalysis pass to LICM causes opt to get stuck in addPass
- [LLVMdev] Infinite loop when adding a new analysis pass
- [LLVMdev] pass utilizing MemoryDependenceAnalysis?
- [LLVMdev] Function Pass Manager
- [LLVMdev] pass utilizing MemoryDependenceAnalysis?