<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        text-align:justify;
        text-justify:inter-ideograph;
        font-size:10.5pt;
        font-family:DengXian;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin:0cm;
        text-align:justify;
        text-justify:inter-ideograph;
        text-indent:21.0pt;
        font-size:10.5pt;
        font-family:DengXian;}
span.pl-c1
        {mso-style-name:pl-c1;}
.MsoChpDefault
        {mso-style-type:export-only;}
/* Page Definitions */
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1160271956;
        mso-list-type:hybrid;
        mso-list-template-ids:-1813768562 -1 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:39.0pt;
        text-indent:-18.0pt;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-text:"%2\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:63.0pt;
        text-indent:-21.0pt;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        margin-left:84.0pt;
        text-indent:-21.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:105.0pt;
        text-indent:-21.0pt;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-text:"%5\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:126.0pt;
        text-indent:-21.0pt;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        margin-left:147.0pt;
        text-indent:-21.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:168.0pt;
        text-indent:-21.0pt;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-text:"%8\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:189.0pt;
        text-indent:-21.0pt;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        margin-left:210.0pt;
        text-indent:-21.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style>
</head>
<body lang="ZH-CN" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">LLVM Developers,</span></p>
<p class="MsoNormal"><span lang="EN-US">       Hi!</span></p>
<p class="MsoNormal"><span lang="EN-US">       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</span>…<span lang="EN-US"> I am aware of the email sent by Y Liu and titled
</span>“<span lang="EN-US">how to add my own passes to LTO pass</span>”<span lang="EN-US">. But it doesn</span>’<span lang="EN-US">t seem to work for the new pass manager. A few questions:</span></p>
<p class="MsoListParagraph" style="margin-left:39.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span class="pl-c1"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><span style="mso-list:Ignore">1.<span style="font:7.0pt "Times New Roman""> 
</span></span></span></span><![endif]><span lang="EN-US">The legacy pass manager has an extension point, `PassManagerBuilder::EP_FullLinkTimeOptimizationLast`. Unfortunately, I can</span>’<span lang="EN-US">t find a alternative in the new pass manager. The
 `Bye` example seems to suggest using `PB.<span class="pl-c1">registerVectorizerStartEPCallback`. I am not sure whether doing so will result in my module pass being ran at compile or link time?</span></span><span class="pl-c1"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><o:p></o:p></span></span></p>
<p class="MsoListParagraph" style="margin-left:39.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span class="pl-c1"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><span style="mso-list:Ignore">2.<span style="font:7.0pt "Times New Roman""> 
</span></span></span></span><![endif]><span class="pl-c1"><span lang="EN-US">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 </span>…<span lang="EN-US">`. 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</span>’<span lang="EN-US">t. Could  you shed some light on how clang
 and lld cope with each other during lto?</span></span><span class="pl-c1"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><o:p></o:p></span></span></p>
<p class="MsoListParagraph" style="margin-left:39.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<![if !supportLists]><span class="pl-c1"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><span style="mso-list:Ignore">3.<span style="font:7.0pt "Times New Roman""> 
</span></span></span></span><![endif]><span class="pl-c1"><span lang="EN-US">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?</span></span><span class="pl-c1"><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin-left:21.0pt"><span class="pl-c1"><span lang="EN-US">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!<o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="pl-c1"><span lang="EN-US"><o:p> </o:p></span></span></p>
<p class="MsoNormal"><span class="pl-c1"><span lang="EN-US">Best Wishes,<o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="pl-c1"><span lang="EN-US">Chibin Zhang<o:p></o:p></span></span></p>
<p class="MsoNormal"><span class="pl-c1"><span lang="EN-US">2021.5.8</span></span><span lang="EN-US" style="font-size:12.0pt;font-family:SimSun"><o:p></o:p></span></p>
</div>
</body>
</html>