[llvm-dev] Error when invoking poolalloc pass with xclang

John Criswell via llvm-dev llvm-dev at lists.llvm.org
Mon Sep 12 07:54:23 PDT 2016


On 9/2/16 3:34 PM, fee via llvm-dev wrote:
> 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.

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:

 1. Try to load the AssistDS library before the DSA library.
 2. Modify Clang to statically link in and run the DSA passes that you need.
 3. Modify libLTO to run the passes that are using DSA.


SAFECode uses the last two options to run its passes.  You can find the 
Clang modifications at:

http://llvm.org/viewvc/llvm-project/safecode/branches/release_32/tools/clang/lib/CodeGen/BackendUtil.cpp?view=log

... and the libLTO modifications at:

http://llvm.org/viewvc/llvm-project/safecode/branches/release_32/tools/LTO/

The code is for LLVM 3.2, but the principles are the same.

Regards,

John Criswell
>
> 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
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
http://www.cs.rochester.edu/u/criswell

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160912/19bfd049/attachment.html>


More information about the llvm-dev mailing list