Error when invoking poolalloc pass with xclang

Hi all,

I wrote a hello world pass that uses the legacy pass manager so I can invoke it directly with clang.
I took the pass skeleton from https://github.com/sampsyo/llvm-pass-skeleton and only added the DSA analysis from poolalloc.
However, as soon as I add the analysis and set the pass via clang I get an error:

Pass 'Allocator Identification Analysis (find malloc/free wrappers)' is not initialized.
Verify if there is a pass dependency cycle.
Required Passes:
clang: LegacyPassManager.cpp:641: void llvm::PMTopLevelManager::schedulePass(llvm::Pass *): Assertion `PI && "Expected required passes to be initialized"' failed.

Invoke:

clang -Xclang -load -Xclang llvm-dsa/lib/LLVMDataStructure.so -Xclang -load -Xclang llvm-pass-skeleton/build/skeleton/libSkeletonPass.so test.c

Pass code:

#include "llvm/Pass.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"

#include "dsa/DataStructure.h"

using namespace llvm;

namespace {
struct SkeletonPass : public FunctionPass {
  static char ID;
  SkeletonPass() : FunctionPass(ID) {}

  void getAnalysisUsage(AnalysisUsage &AU) const {
    AU.addRequiredTransitive<EQTDDataStructures>();
  }

  virtual bool runOnFunction(Function &F) {
    errs() << "I saw a function called " << F.getName() << "!\n";
    return false;
  }
};
}

char SkeletonPass::ID = 0;

static void registerDfi(const PassManagerBuilder &, legacy::PassManagerBase &PM) {
  PM.add(new SkeletonPass());
}

static RegisterStandardPasses RegisterMyPass(PassManagerBuilder::EP_EarlyAsPossible, registerDfi);

From the error I guess I need to initialize the Allocator Identification Analysis.

However, I don't know how to do this.
Can someone help?

Thank you!

-Fredi

You’re most likely getting this error because you aren’t loading the dynamic libraries that implement passes upon which DSA relies. IIRC, some of the DSA passes depend upon passes in the AssistDS library. There are three options you could try: SAFECode uses the last two options to run its passes. You can find the Clang modifications at: … and the libLTO modifications at: The code is for LLVM 3.2, but the principles are the same. Regards, John Criswell