LLVM assertion error using AliasAnalysis in pass module

I am having a problem using AliasAnalysis from pass module (LLVM 3.4). This seems to be a fairly common problem with two main solutions, but I haven't been able to get it to work.

With the following simple test program:

#include <stdio.h>

static int gX;

void f() {
  gX = 1;
}

int main() {
  printf("Hello.\n");
  return 0;
}

      

Compiled like this: clang++ -O0 -c -emit-llvm -o test.bc test.cpp

And my simple pass:

class DebugPass : public ModulePass {
public:
  static char ID;
  DebugPass() : ModulePass(ID) {}

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

  virtual bool runOnModule(Module &M) {
    for (Module::iterator fit = M.begin(), fite = M.end(); fit != fite; ++fit) {
      Function *F = fit;
      if (F->isDeclaration()) continue;
      errs() << "Getting AA for " << F->getName() << "\n";
      AliasAnalysis &AA = getAnalysis<AliasAnalysis>(*F);
    }
    return false;
  }
}
char DebugPass::ID = 0;
static RegisterPass<DebugPass> X("testdebug", "Debugging pass", false, false);

      

And, calling my pass like so: opt -load ../Debug+Asserts/lib/TestLib.dylib -basicaa -testdebug < test.bc > /dev/null

I see the following statement:

Getting AA for _Z1fv
Assertion failed: (FPP && "Unable to find on the fly pass"), function getOnTheFlyPass, file LegacyPassManager.cpp, line 1682.
...
6  opt                      0x0000000102e5ba62 abort + 18
7  opt                      0x0000000102e5ba41 __assert_rtn + 129
8  opt                      0x0000000102d94820 (anonymous namespace)::MPPassManager::getOnTheFlyPass(llvm::Pass*, void const*, llvm::Function&) + 144
9  opt                      0x0000000102d949cf non-virtual thunk to (anonymous namespace)::MPPassManager::getOnTheFlyPass(llvm::Pass*, void const*, llvm::Function&) + 63
10 opt                      0x0000000102d8ed4e llvm::AnalysisResolver::findImplPass(llvm::Pass*, void const*, llvm::Function&) + 78
11 TestLib.dylib           0x0000000104ba9bac llvm::AliasAnalysis& llvm::Pass::getAnalysisID<llvm::AliasAnalysis>(void const*, llvm::Function&) + 236
12 TestLib.dylib           0x0000000104b9eef6 llvm::AliasAnalysis& llvm::Pass::getAnalysis<llvm::AliasAnalysis>(llvm::Function&) + 134
13 TestLib.dylib           0x0000000104bdc287 DebugPass::runOnModule(llvm::Module&) + 215

      

Can anyone provide an idea of ​​what is going wrong?

Edit: here is the structure for walking through -debug-pass=Structure

:

Pass Arguments:  -targetlibinfo -datalayout -notti -basictti -x86tti -no-aa -basicaa -testdebug -preverify -domtree -verify
Target Library Information
Data Layout
No target information
Target independent code generator TTI
X86 Target Transform Info
No Alias Analysis (always returns 'may' alias)
Basic Alias Analysis (stateless AA impl)
  ModulePass Manager
    Debugging pass
    FunctionPass Manager
      Preliminary module verification
      Dominator Tree Construction
      Module Verifier
    Bitcode Writer

      

How important is it that my debug pass occurs before the FunctionPass manager? I am not good at interpreting the output of a pass structure.

+3


source to share





All Articles