[llvm-dev] A Few Questions Regarding The New Pass Manager, LTO, and LLD

Arthur Eubanks via llvm-dev llvm-dev at lists.llvm.org
Mon May 10 12:39:54 PDT 2021


On Sat, May 8, 2021 at 8:15 AM 张驰斌 via llvm-dev <llvm-dev at lists.llvm.org>
wrote:

> LLVM Developers,
>
>        Hi!
>
>        There is a scenario where I want to do full program analysis,
> ideally after link time optimization is done and before assembly is
> emitted, when all symbols are in LLVM IR form and contained in a single
> module. But after some time browsing stackoverflow, lld documentation, and
> the mailing lists, I still have little clue how to do it… I am aware of
> the email sent by Y Liu and titled “how to add my own passes to LTO pass”.
> But it doesn’t seem to work for the new pass manager. A few questions:
>
> 1.  The legacy pass manager has an extension point,
> `PassManagerBuilder::EP_FullLinkTimeOptimizationLast`. Unfortunately, I can
> ’t find a alternative in the new pass manager. The `Bye` example seems to
> suggest using `PB.registerVectorizerStartEPCallback`. I am not sure
> whether doing so will result in my module pass being ran at compile or link
> time?
>
Feel free to create a patch to add a PassBuilder equivalent
of EP_FullLinkTimeOptimizationLast.

> 2.  I wonder how does clang communicates passes that need to be run at
> lto to lld. The command line that I attempt to get lto running is `clang
> -fexperimental-new-pass-manager -fpass-plugin=libmymodulepass.so -flto
> -fuse-ld=lld …`. I straced the command for execv calls, and expected to
> see libmymodulepass.so to be passed to ld.lld as an argument, but found out
> it wasn’t. Could  you shed some light on how clang and lld cope with each
> other during lto?
>
I don't know pass plugins that well, but maybe llvm/examples/Bye/Bye.cpp
and its surrounding infrastructure may help?

> 3.  Greping `ld.lld --help` reveals an interesting option:
> `--lto-newpm-passes=<value>`. Does the <value> here mean built-in pass
> names like `dce`/`mem2reg`, or is it an option to insert our plugin like
> libmymodulepass.so?
>
> I’ve looking into this for a while but haven’t made much progress…Any
> examples / command line on how to do this are greatly appreciated!
>
>
>
> Best Wishes,
>
> Chibin Zhang
>
> 2021.5.8
> _______________________________________________
> 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/20210510/92ac5ad6/attachment.html>


More information about the llvm-dev mailing list