[llvm-dev] Function optimization pass

Philip Pfaffe via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 21 05:00:19 PDT 2018


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/08488781/attachment.html>


More information about the llvm-dev mailing list