<html xmlns:v="urn:schemas-microsoft-com:vml" 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)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:宋体;
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:等线;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"\@等线";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:宋体;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin:0cm;
margin-bottom:.0001pt;
text-indent:21.0pt;
font-size:12.0pt;
font-family:宋体;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:宋体;}
span.EmailStyle18
{mso-style-type:personal;
font-family:等线;
color:windowtext;}
span.EmailStyle20
{mso-style-type:personal-compose;
font-family:等线;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@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:2124642432;
mso-list-type:hybrid;
mso-list-template-ids:923703864 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:21.0pt;
text-indent:-21.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:42.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:63.0pt;
text-indent:-21.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:84.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:105.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:126.0pt;
text-indent:-21.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
margin-left:147.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:168.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:189.0pt;
text-indent:-21.0pt;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=ZH-CN link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:等线'>I have considered user-custom derivatives. I think we can define proc-macros that allows users to use their own defined derivatives (instead of ones generated by Enzyme) in this project, then the registration of frequently-used functions’ derivatives can be implemented in a separated projects.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:等线'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:等线'>So, if not misunderstood, the outline of the project is thus:<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:21.0pt;text-indent:-21.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US style='font-size:10.5pt;font-family:等线'><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-US style='font-size:10.5pt;font-family:等线'>a Rust metadata parser and some modification to Enzyme to use the parsed metadata<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:21.0pt;text-indent:-21.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US style='font-size:10.5pt;font-family:等线'><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-US style='font-size:10.5pt;font-family:等线'>a Rust-specific optimization pass or extending the Rust compiler<o:p></o:p></span></p><p class=MsoListParagraph style='margin-left:21.0pt;text-indent:-21.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-US style='font-size:10.5pt;font-family:等线'><span style='mso-list:Ignore'>3.<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-US style='font-size:10.5pt;font-family:等线'>some utilities to provide handlers to Rust to implement the fore-mentioned functions, like user-defined derivatives and indicating markers<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:等线'>As to the Rust API, it can be implemented in Manuel Drehwald’s project. The 3<sup>rd</sup> part may seems to overlap with that, but essentially, in my idea, the 3<sup>rd</sup> part of the GSoC project will only contains the minimal set to make Enzyme function well in Rust, and the rest will be left to Manuel Drehwald’s project.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:等线'><o:p> </o:p></span></p><div><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:等线'>If there’s no problem, I’ll further dive into the 1<sup>st</sup>, 2<sup>nd</sup>, and 3<sup>rd</sup> part sequentially, and write a draft of the proposal soon.<o:p></o:p></span></p><div style='mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt;padding:0cm 0cm 1.0pt 0cm'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:justify;text-justify:inter-ideograph;border:none;padding:0cm'><span lang=EN-US style='font-family:等线'><o:p> </o:p></span></p></div><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right'><span lang=EN-US style='font-size:9.0pt;font-family:等线'>Chuyang Chen<o:p></o:p></span></p><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right;word-break:break-all'><span lang=EN-US style='font-size:9.0pt;font-family:等线'>MSc Student<o:p></o:p></span></p><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right;word-break:break-all'><span lang=EN-US style='font-size:9.0pt;font-family:等线'>At Department of Computer Science and Technology, Nanjing University<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:justify;text-justify:inter-ideograph'><span lang=EN-US style='font-size:10.5pt;font-family:等线'><o:p> </o:p></span></p></div><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:等线'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'> William Moses <wmoses@mit.edu> <br><b>Sent:</b> Friday, April 2, 2021 12:01 PM<br><b>To:</b> Chuyang Chen <chuyangchen@foxmail.com><br><b>Cc:</b> William Moses <wmoses@mit.edu>; llvm-dev <llvm-dev@lists.llvm.org>; Enzyme AD <enzyme-dev@googlegroups.com><br><b>Subject:</b> Re: Re: FW: [GSoC 2021] Some ideas & questions about the Enzyme GSoC project<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><div><p class=MsoNormal><span lang=EN-US>Regarding debug information, yeah it's not necessarily the best mechanism (obviously that would be direct Rust compiler integration), but I believe it should be sufficient at least for now. Presumably, we can always run a pass that removes debug info after Enzyme if the extra information becomes a concern.<br><br>I think your understanding of the project components is mostly correct. The one thing that I might add (and of course there's a lot here, not all of which needs completion during GSOC) is potential registration of custom derivatives for various rust internal routines/allocation mechanisms, and possibly marking explicitly the activity analysis markers of routines such as print to be inactive. The second bit is to clarify that Enzyme, by virtue of being an LLVM pass natively has support for LLVM Metadata. The specific issue here is parsing the specific layout of Rust types in the metadata into something more easily digestible to LLVM/Enzyme type analysis.<br><br>Manuel Drehwald (trying to find email and will add to cc) has recently been looking into exporting the Enzyme C API as a crate to be called from Rust. Once that exists, we can extend the Rust compiler or perhaps create a special Rust-specific optimization pass that calls the Enzyme API with the Type metadata parsing to perform end-to-end tests.<br><br>If you're looking to dive right in, I'd probably suggest pushing either the metadata parsing or Rust plugin (or custom codegen pass) as next steps.<o:p></o:p></span></p></div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><div><div><p class=MsoNormal><span lang=EN-US>On Wed, Mar 31, 2021 at 7:21 AM Chuyang Chen <<a href="mailto:chuyangchen@foxmail.com" target="_blank">chuyangchen@foxmail.com</a>> wrote:<o:p></o:p></span></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:10.5pt;font-family:等线'>The metadata parser in the </span><span lang=EN-US><a href="https://github.com/tiberiusferreira/oxide-enzyme/issues/1#issuecomment-735634144" target="_blank"><span style='font-size:10.5pt;font-family:等线'>github discussion</span></a></span><span lang=EN-US style='font-size:10.5pt;font-family:等线'> seems to work on debuginfo. It means that each time we want Enzyme to work, we should add a </span><span style='font-size:10.5pt;font-family:等线'>“<span lang=EN-US>-g</span>”<span lang=EN-US> option to the compiling command </span>“<span lang=EN-US>rustc</span>”<span lang=EN-US>. I</span>’<span lang=EN-US>m a bit in doubt whether this will be OK though it doesn</span>’<span lang=EN-US>t make much difference. But will there be some cases, like running on a device whose memory is limited, where adding debuginfo do have some negative effect? Anyway, this may be the most fitting way.</span></span><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:10.5pt;font-family:等线'> </span><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:10.5pt;font-family:等线'>Now, AIUI, there are 4 things need to be done in the project:</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-left:18.0pt'><span lang=EN-US style='font-size:10.5pt;font-family:等线'>1.</span><span lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> </span><span lang=EN-US style='font-size:10.5pt;font-family:等线'>writing a parser parsing LLVM metadata and passing it to Enzyme</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-left:18.0pt'><span lang=EN-US style='font-size:10.5pt;font-family:等线'>2.</span><span lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> </span><span lang=EN-US style='font-size:10.5pt;font-family:等线'>adjusting Enzyme to leverage the metadata</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-left:18.0pt'><span lang=EN-US style='font-size:10.5pt;font-family:等线'>3.</span><span lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> </span><span lang=EN-US style='font-size:10.5pt;font-family:等线'>writing a Rust crate to provide APIs to Rust user</span><span lang=EN-US><o:p></o:p></span></p><p style='margin-left:18.0pt'><span lang=EN-US style='font-size:10.5pt;font-family:等线'>4.</span><span lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> </span><span lang=EN-US style='font-size:10.5pt;font-family:等线'>writing a Rust compiler patch to allow importing LLVM plugins to the Rust compiler</span><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:10.5pt;font-family:等线'>Is that right?</span><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:10.5pt;font-family:等线'> </span><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'> William Moses <</span><span lang=EN-US><a href="mailto:wmoses@mit.edu" target="_blank"><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>wmoses@mit.edu</span></a></span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>> <br><b>Sent:</b> Wednesday, March 31, 2021 10:51 AM<br><b>To:</b> Chuyang Chen <</span><span lang=EN-US><a href="mailto:chuyangchen@foxmail.com" target="_blank"><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>chuyangchen@foxmail.com</span></a></span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>><br><b>Cc:</b> Billy Moses <</span><span lang=EN-US><a href="mailto:wmoses@mit.edu" target="_blank"><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>wmoses@mit.edu</span></a></span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>>; llvm-dev <</span><span lang=EN-US><a href="mailto:llvm-dev@lists.llvm.org" target="_blank"><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>llvm-dev@lists.llvm.org</span></a></span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>>; Enzyme AD <</span><span lang=EN-US><a href="mailto:enzyme-dev@googlegroups.com" target="_blank"><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>enzyme-dev@googlegroups.com</span></a></span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>><br><b>Subject:</b> Re: FW: [GSoC 2021] Some ideas & questions about the Enzyme GSoC project</span><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>There's certainly utility to be gained by hooking into the rust compiler. At minimum this allows us to effectively integrate high level functions for calling into Enzyme as an API without going through FFI.<br><br>As you say, one of the biggest issues here is essentially parsing Rust types. This actually may not require a modification to rustc as I believe this is available in LLVM as LLVM metadata (see <a href="https://github.com/tiberiusferreira/oxide-enzyme/issues/1#issuecomment-735634144" target="_blank">https://github.com/tiberiusferreira/oxide-enzyme/issues/1#issuecomment-735634144</a> for an earlier discussion on this topic specifically).<br><br>It turns out that one doesn't need to piggyback off LLD if rustc itself can call the custom LLVM pass which runs Enzyme. This could be done by say loading a plugin to rust, or otherwise calling the API. Of course in general enabling better integration of LLVM internals/pass plugins into rust directly is potentially desirable. I recently proposed a patch to rustc that would allow importing LLVM plugins that may be worth a look (see <a href="https://github.com/rust-lang/compiler-team/issues/419" target="_blank">https://github.com/rust-lang/compiler-team/issues/419</a> <a href="https://github.com/rust-lang/rust/pull/82734" target="_blank">https://github.com/rust-lang/rust/pull/82734</a>). That said such support isn't a blocker, as much as we need to start parsing this metadata. In theory we can even fork the "nice interface" and "parsing metadata" into two concurrent projects/pieces.<o:p></o:p></span></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>On Tue, Mar 30, 2021 at 12:04 PM Chuyang Chen <<a href="mailto:chuyangchen@foxmail.com" target="_blank">chuyangchen@foxmail.com</a>> wrote:<o:p></o:p></span></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>A thing I forgot to mention is that a Rust feature named </span>“<span lang=EN-US>compiler plugin</span>”<span lang=EN-US> do satisfy the requirement of </span>“<span lang=EN-US>emitting extra debuginfo to the generated IR code</span>”<span lang=EN-US>, but it</span>’<span lang=EN-US>s unstable and won</span>’<span lang=EN-US>t be stabilized in the foreseeable future. Moreover, as to </span>“<span lang=EN-US>using lld as its linker and add the Enzyme pass to lld</span>”<span lang=EN-US>, compiler plugins help nothing.<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Chuyang Chen <</span><span lang=EN-US><a href="mailto:chuyangchen@foxmail.com" target="_blank"><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>chuyangchen@foxmail.com</span></a></span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>> <br><b>Sent:</b> Tuesday, March 30, 2021 11:44 PM<br><b>To:</b> </span><span lang=EN-US><a href="mailto:wmoses@mit.edu" target="_blank"><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>wmoses@mit.edu</span></a></span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'><br><b>Cc:</b> </span><span lang=EN-US><a href="mailto:llvm-dev@lists.llvm.org" target="_blank"><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>llvm-dev@lists.llvm.org</span></a></span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>; 'Enzyme AD' <</span><span lang=EN-US><a href="mailto:enzyme-dev@googlegroups.com" target="_blank"><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>enzyme-dev@googlegroups.com</span></a></span><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri",sans-serif'>><br><b>Subject:</b> [GSoC 2021] Some ideas & questions about the Enzyme GSoC project</span><span lang=EN-US><o:p></o:p></span></p></div></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>Hello, I</span>’<span lang=EN-US>m working on the GSoC project </span>“<span lang=EN-US>Integrate Enzyme into Rust to provide high-performance differentiation in Rust</span>”<span lang=EN-US>. I have skimmed over the codebase and now I have some preliminary ideas about the project.<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>As you have said, the project can be divided to two main parts:<o:p></o:p></span></p><p style='margin-left:18.0pt'><span lang=EN-US>1.</span><span lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> </span><span lang=EN-US>passing and parsing Rust type metadata into LLVM / Enzyme type analysis, and<o:p></o:p></span></p><p style='margin-left:18.0pt'><span lang=EN-US>2.</span><span lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> </span><span lang=EN-US>integrating the Enzyme API/pass into rust.<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>Integrating Enzyme API to rust is trivial by using proc_macros in Rust. However, passing Rust type metadata to LLVM and integrating the Enzyme pass into rust is difficult if we don</span>’<span lang=EN-US>t modify the Rust compiler. The Rust compiler seems to lack ability to emit metadata to LLVM, and if we want to add the Enzyme pass without modifying the compiler, the only way is, I think, using a command like<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US><img border=0 width=860 height=25 style='width:8.9583in;height:.2604in' id="gmail-m_-7236394230511152334gmail-m_-3420938107842278483gmail-m_-6253693781121381657图片_x0020_1" src="cid:image003.png@01D728DB.A486B740" alt="cid:image003.png@01D725BE.92A91F10"></span><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>which is not user-friendly. I sought hard for a nonintrusive way to implement them but got nothing, so it seems that the only option is modifying the Rust compiler to let it<o:p></o:p></span></p><p style='margin-left:18.0pt'><span lang=EN-US>1.</span><span lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> </span><span lang=EN-US>emit extra debuginfo to the generated IR code, and<o:p></o:p></span></p><p style='margin-left:18.0pt'><span lang=EN-US>2.</span><span lang=EN-US style='font-size:7.0pt;font-family:"Times New Roman",serif'> </span><span lang=EN-US>use lld as its linker and add the Enzyme pass to lld<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>with a specific option, say </span>“<span lang=EN-US>--enzyme</span>”<span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>However, <i>is it appropriate to modify the compiler to just port a plugin to it, though the modification won</i></span><i>’<span lang=EN-US>t be big or impact the rest of the compiler?</span></i><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>PS: Another question is about differentiating closures in Rust, but that can be postponed to the following discussions.<o:p></o:p></span></p><div style='border:none;border-bottom:solid windowtext 1.0pt;padding:0cm 0cm 1.0pt 0cm'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p></div><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right;word-break:break-all'><span lang=EN-US>Chuyang Chen<o:p></o:p></span></p><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right;word-break:break-all'><span lang=EN-US>MSc Student<o:p></o:p></span></p><p class=MsoNormal align=right style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-align:right;word-break:break-all'><span lang=EN-US>At Department of Computer Science and Technology, Nanjing University<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US> <o:p></o:p></span></p></div></div></blockquote></div></div></div></blockquote></div></div></body></html>