Hi,<br><br>I am running into the same issue with a module pass, that calls LoopInfo.(does not call DominatorTree)<br><br>I am using RegisterPass, since it is a dynamically loaded module(as per lib/Transforms/Hello)<br><br>

It does seem possible from the discussion, to use LoopInfo inside a ModulePass.<br><br>I am wondering what the fix to this problem was.<br><br>Also, the code works in 2.7.(I did not try 2.8)<br><br>Thanks,<br>Arushi<br><br>

<div class="gmail_quote">On Tue, May 3, 2011 at 6:18 PM, Michael Ilseman <span dir="ltr"><<a href="mailto:michael@lunarg.com">michael@lunarg.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

When migrating my project to 2.9, I've encountered a strange segfault<br>
where if a ModulePass's getAnalysisUsage adds LoopInfo and<br>
DominatorTree, then llvm::PMTopLevelManager::findAnalysisUsage will<br>
segfault. What's odd is that if I rearrange this (add required for<br>
DominatorTree before LoopInfo), it does not segfault. I realize that<br>
LoopInfo requires and preserves DominatorTree, but this behavior is<br>
strange. All my other passes migrated fine (after adding in code to do<br>
the initializations), but perhaps I'm still not initializing<br>
everything properly?. Below is an example program and it's stack trace<br>
and debug info.<br>
<br>
#include "llvm/Pass.h"<br>
#include "llvm/PassManager.h"<br>
#include "llvm/Analysis/Dominators.h"<br>
#include "llvm/Analysis/LoopInfo.h"<br>
<br>
using namespace llvm;<br>
<br>
// Forward decl<br>
namespace llvm {<br>
    void initializeFooPass(PassRegistry&);<br>
} // end namespace llvm<br>
<br>
namespace  {<br>
    class Foo : public ModulePass {<br>
    public:<br>
        Foo() : ModulePass(ID) {<br>
            initializeFooPass(*PassRegistry::getPassRegistry());<br>
        }<br>
<br>
        ~Foo() { }<br>
<br>
        static char ID;<br>
        bool runOnModule(Module&);<br>
        void print(std::ostream&, const Module*) const;<br>
        void getAnalysisUsage(AnalysisUsage&) const;<br>
    };<br>
} // end namespace<br>
<br>
bool Foo::runOnModule(Module &M) {<br>
    return false;<br>
}<br>
<br>
void Foo::getAnalysisUsage(AnalysisUsage &AU) const {<br>
    AU.addRequired<LoopInfo>();<br>
    AU.addRequired<DominatorTree>();<br>
}<br>
<br>
void Foo::print(std::ostream&, const Module*) const { }<br>
<br>
char Foo::ID = 0;<br>
INITIALIZE_PASS_BEGIN(Foo, "foo", "foo bar", true, true)<br>
INITIALIZE_PASS_DEPENDENCY(LoopInfo)<br>
INITIALIZE_PASS_DEPENDENCY(DominatorTree)<br>
INITIALIZE_PASS_END(Foo, "foo", "foo bar", true, true)<br>
<br>
Foo *createFooPass() {<br>
    return new Foo();<br>
}<br>
<br>
void runFooPass(Module &M)<br>
{<br>
    PassManager PM;<br>
    PM.add(createFooPass());<br>
    PM.run(M);<br>
}<br>
<br>
<br>
Program received signal SIGSEGV, Segmentation fault.<br>
<br>
#0  0x0832312f in llvm::PMTopLevelManager::findAnalysisUsage<br>
(this=0x86f798c, P=0x892bfc0) at<br>
<...>/llvm-2.9/lib/VMCore/PassManager.cpp:577<br>
#1  0x08322cfb in llvm::PMTopLevelManager::setLastUser<br>
(this=0x86f798c, AnalysisPasses=..., P=0x892d2e0) at<br>
<...>/llvm-2.9/lib/VMCore/PassManager.cpp:516<br>
#2  0x083275f5 in llvm::MPPassManager::addLowerLevelRequiredPass<br>
(this=0x885cc60, P=0x892d2e0, RequiredPass=0x892bfc0) at<br>
<...>/llvm-2.9/lib/VMCore/PassManager.cpp:1608<br>
#3  0x08324cef in llvm::PMDataManager::add (this=0x885cc70,<br>
P=0x892d2e0, ProcessAnalysis=true) at<br>
<...>/llvm-2.9/lib/VMCore/PassManager.cpp:989<br>
#4  0x08327f11 in llvm::ModulePass::assignPassManager (this=0x892d2e0,<br>
PMS=..., PreferredType=llvm::PMT_ModulePassManager) at<br>
<...>/llvm-2.9/lib/VMCore/PassManager.cpp:1768<br>
#5  0x08329b11 in llvm::PassManagerImpl::addTopLevelPass<br>
(this=0x885cab8, P=0x892d2e0) at<br>
<...>/llvm-2.9/lib/VMCore/PassManager.cpp:423<br>
#6  0x0832339f in llvm::PMTopLevelManager::schedulePass<br>
(this=0x885cb8c, P=0x892d2e0) at<br>
<...>/llvm-2.9/lib/VMCore/PassManager.cpp:639<br>
#7  0x083299dc in llvm::PassManagerImpl::add (this=0x885cab8,<br>
P=0x892d2e0) at <...>/llvm-2.9/lib/VMCore/PassManager.cpp:396<br>
#8  0x083279e5 in llvm::PassManager::addImpl (this=0xbffe9578,<br>
P=0x892d2e0) at <...>/llvm-2.9/lib/VMCore/PassManager.cpp:1659<br>
#9  0x08327b0a in llvm::PassManager::add (this=0xbffe9578,<br>
P=0x892d2e0) at <...>/llvm-2.9/lib/VMCore/PassManager.cpp:1672<br>
#10 0x08089480 in runFooPass (M=...) at <...>/Hello.h:56<br>
...<br>
<br>
At that point, the variable "P" is<br>
<br>
$9 = {_vptr.Pass = 0x0, Resolver = 0x0, PassID = 0x8533e00, Kind =<br>
llvm::PT_Function}<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br>