[LLVMdev] Crash on AU.addRequired<LoopInfo>();

Pankaj Kohli pankaj208 at gmail.com
Wed May 6 21:21:34 PDT 2015


Hi,

I have a simple Function pass, and I am trying to get loop info in the
code. But when I try to add AU.addRequired<LoopInfo>(); in
getAnalysisUsage(), the module crashes. This happens even before
getAnalysis<LoopInfo>() is called. It is a dynamically loaded pass (.so).

namespace
{
    class TestPass : public FunctionPass
    {
        public:
        static char ID;

        TestPass() : FunctionPass(ID) {}

        virtual void getAnalysisUsage(AnalysisUsage &AU) const
        {
            AU.addRequired<LoopInfo>();
            AU.setPreservesAll();
        }

        bool runOnFunction(Function &F) override
        {
            errs() << F.getName() << " : " << F.getBasicBlockList().size()
<< "\n";
            // LoopInfo &LI = getAnalysis<LoopInfo>();
            return false;
        }
    };
}

char TestPass::ID = 0;
static RegisterPass<TestPass> X("TestPass", "Test pass");

// register pass for clang use
static void registerTestPassPass(const PassManagerBuilder &,
PassManagerBase &PM)
{
    PM.add(new TestPass());
}

static RegisterStandardPasses
RegisterTestPassPass(PassManagerBuilder::EP_EarlyAsPossible ,
registerTestPassPass);


Here is the stack trace.
[armeabi-v7a] Compile thumb  : test <= test.c

Pass 'Test pass' is not initialized.
Verify if there is a pass dependency cycle.
Required Passes:
0  clang           0x0000000001492ec2 llvm::sys::PrintStackTrace(_IO_FILE*)
+ 34
1  clang           0x0000000001490f61
2  libpthread.so.0 0x00002b15cbb4e340
3  clang           0x00000000011c86f7
llvm::PMTopLevelManager::schedulePass(llvm::Pass*) + 343
4  clang           0x00000000019c0401
llvm::PassManagerBuilder::addExtensionsToPM(llvm::PassManagerBuilder::ExtensionPointTy,
llvm::legacy::PassManagerBase&) const + 225
5  clang           0x00000000019c054a
llvm::PassManagerBuilder::populateFunctionPassManager(llvm::legacy::FunctionPassManager&)
+ 26
6  clang           0x0000000001837de3
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&,
llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) +
1171
7  clang           0x000000000182a47f
8  clang           0x0000000001bdf043 clang::ParseAST(clang::Sema&, bool,
bool) + 483
9  clang           0x0000000001603ba6 clang::FrontendAction::Execute() + 118
10 clang           0x00000000015e47b8
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 280
11 clang           0x0000000001673b41
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1921
12 clang           0x0000000000820358 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 1320
13 clang           0x00000000007fceaa main + 8298
14 libc.so.6       0x00002b15cc7b6ec5 __libc_start_main + 245
15 clang           0x000000000081e5d9



Am I missing something? Any help would be appreciated.

Thanks,
Pankaj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150507/b3e00180/attachment.html>


More information about the llvm-dev mailing list