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

张驰斌 via llvm-dev llvm-dev at lists.llvm.org
Sat May 8 08:14:50 PDT 2021


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?

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?

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210508/2ee465d9/attachment.html>


More information about the llvm-dev mailing list