[llvm-dev] Function optimization pass

Ta Thanh Dinh via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 21 05:32:03 PDT 2018


Hi Philip,

Thanks for the response. Under llvm-5.0.2 and llvm-6.0.1 in Debug mode, the
crash hit at the same assertion:

/usr/local/include/llvm/IR/PassManager.h:689: typename PassT::Result&
llvm::AnalysisManager<IRUnitT, ExtraArgTs>::getResult(IRUnitT&, ExtraArgTs
...) [with PassT =
llvm::InnerAnalysisManagerProxy<llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults&>, llvm::Function>; IRUnitT =
llvm::Function; ExtraArgTs = {}; typename PassT::Result =
llvm::InnerAnalysisManagerProxy<llvm::AnalysisManager<llvm::Loop,
llvm::LoopStandardAnalysisResults&>, llvm::Function>::Result]: Assertion
`AnalysisPasses.count(PassT::ID()) && "This analysis pass was not
registered prior to being queried"' failed.

I'm new to llvm optimization and I still don't know which analysis managers
should be created and populated in this case. Many thanks for any help.


Le mar. 21 août 2018 à 14:00, Philip Pfaffe <philip.pfaffe at gmail.com> a
écrit :

> Can you tell us more about the crash? I.e., do you have a stack dump? Does
> it hit an assertion (if your LLVM is built in Debug mode/has assertions
> enabled)?
>
> Generally, PassBuilder and passes likely assume a full stack of analysis
> managers. You should thus create and populate all of them, not just
> FunctionAM, and cross-register their proxies.
>
> Cheers,
> Philip
>
> On Mon, Aug 20, 2018 at 7:29 PM Ta Thanh Dinh via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> This question has been submitted to stackoverflow (
>> https://stackoverflow.com/questions/51934964/function-optimization-pass)
>> but someone suggested me that it should be submitted to llvm-dev mailing
>> list instead. I'm sorry for the duplication.
>>
>> I am trying to use PassBulider and FunctionPassManager to optimize a
>> function in a module, what I have done is:
>>
>>
>> mod = ...load module from LLVM IR bitcode file go_back.bc...
>>
>> auto lift_func = mod->getFunction("go_back");
>> if (not lift_func) {
>>     llvm::errs() << "Error: cannot get function\n";
>>     return 0;
>> }
>>
>> auto pass_builder = llvm::PassBuilder{};
>> auto fa_manager = llvm::FunctionAnalysisManager{};
>>
>> pass_builder.registerFunctionAnalyses(fa_manager);
>> auto fp_manager =
>> pass_builder.buildFunctionSimplificationPipeline(llvm::PassBuilder::OptimizationLevel::O2);
>>
>> fp_manager.run(*lift_func, fa_manager);
>>
>> ...print mod...
>>
>>
>> but the program crashes always at fp_manager.run. Strange enough, LLVM's
>> opt tool (which uses legacy optimization API) works without any problem,
>> i.e if I run
>>
>> opt -O2 go_back.bc -o go_back_o2.bc
>>
>> then I get a new module where the (single) function go_back is optimized.
>>
>> Many thanks for any response.
>>
>> NB. The disassembled LLVM bitcode is at
>> https://gist.github.com/tathanhdinh/23470452910da9f73b857b2e6a12f144 if
>> anyone wants to take a look.
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://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/20180821/a7e65336/attachment.html>


More information about the llvm-dev mailing list