<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 9/2/16 3:34 PM, fee via llvm-dev
      wrote:<br>
    </div>
    <blockquote cite="mid:4ea62a51-5785-e3c9-8331-4d091f7665e0@web.de"
      type="cite">
      <pre wrap="">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 <a class="moz-txt-link-freetext" href="https://github.com/sampsyo/llvm-pass-skeleton">https://github.com/sampsyo/llvm-pass-skeleton</a> 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.</pre>
    </blockquote>
    <br>
    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.<br>
    <br>
    There are three options you could try:<br>
    <br>
    <ol>
      <li>Try to load the AssistDS library before the DSA library.</li>
      <li>Modify Clang to statically link in and run the DSA passes that
        you need.</li>
      <li>Modify libLTO to run the passes that are using DSA.<br>
      </li>
    </ol>
    <br>
    SAFECode uses the last two options to run its passes.  You can find
    the Clang modifications at:<br>
    <br>
<a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-project/safecode/branches/release_32/tools/clang/lib/CodeGen/BackendUtil.cpp?view=log">http://llvm.org/viewvc/llvm-project/safecode/branches/release_32/tools/clang/lib/CodeGen/BackendUtil.cpp?view=log</a><br>
    <br>
    ... and the libLTO modifications at:<br>
    <br>
<a class="moz-txt-link-freetext" href="http://llvm.org/viewvc/llvm-project/safecode/branches/release_32/tools/LTO/">http://llvm.org/viewvc/llvm-project/safecode/branches/release_32/tools/LTO/</a><br>
    <br>
    The code is for LLVM 3.2, but the principles are the same.<br>
    <br>
    Regards,<br>
    <br>
    John Criswell<br>
    <blockquote cite="mid:4ea62a51-5785-e3c9-8331-4d091f7665e0@web.de"
      type="cite">
      <pre wrap="">

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
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
    <br>
    <p><br>
    </p>
    <pre class="moz-signature" cols="72">-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a class="moz-txt-link-freetext" href="http://www.cs.rochester.edu/u/criswell">http://www.cs.rochester.edu/u/criswell</a></pre>
  </body>
</html>