[llvm-dev] Run llvm pass from standalone project

Philip Pfaffe via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 22 04:26:32 PDT 2019


Hi Akash,

this isn't exactly documented, but you can refer to the implementation in
the opt tool (see NewPMDriver.cpp). The problem is that you're missing a
full stack of analysis managers.

Cheers,
Philip

On Mon, Jul 22, 2019 at 11:56 AM Akash Banerjee via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi all,
> I am trying to use LLVM's AliasAnalysis pass, but from a standalone tool
> that uses llvm libraries.
>
> The following is the code snippet I am currently using.
> PassBuilder PB;
> auto mod_manager = ModuleAnalysisManager { };
> PB.registerModuleAnalyses(mod_manager);
> AAResults& AAR = mod_manager.getResult<AAManager>(*M);
>
> But the code fails at .getResult with the following error:
> /llvm/include/llvm/IR/PassManager.h:778: typename PassT::Result&
> llvm::AnalysisManager<IRUnitT, ExtraArgTs>::getResult(IRUnitT&, ExtraArgTs
> ...) [with PassT = llvm::AAManager; IRUnitT = llvm::Module; ExtraArgTs =
> {}; typename PassT::Result = llvm::AAResults]: Assertion
> `AnalysisPasses.count(PassT::ID()) && "This analysis pass was not
> registered prior to being queried"' failed.
> Aborted (core dumped)
>
> Please point me towards some documentation that explains how to run llvm
> passes from a standalone project.
>
> Thanks,
> Akash Banerjee
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190722/167a8e7c/attachment.html>


More information about the llvm-dev mailing list