<div dir="ltr"><div>Thanks for the pointers, Simon. Some more specific questions:</div><div><br></div><div>* To access an unfolding, is `maybeUnfoldingTemplate (idUnfolding v)` the recommended recipe?</div><div>* Is it the case that this recipe succeeds (`Just`) in some compiler phases and not others?</div><div> If so, is this difference due to Ids being altered (presumably via `setUnfoldingInfo` being called between phases)?</div><div>* Before an Id is ready for general inlining by the simplifier, can I get the Id's unfolding another way so that I can substitute it early?</div><div><br></div><div>A short Skype chat might easily clear up my questions and confusions if you have time and inclination.</div><div><br></div><div>Regards, - Conal</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 2, 2016 at 9:07 AM, Simon Peyton Jones <span dir="ltr"><<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="m_-7758154365819351883WordSection1">
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif">I don’t really understand your question clearly. So I’ll guess<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif">Unfoldings are added to Ids in Simplify.completeBind (look for setUnfoldingInfo). Apart from INLINE pragmas, that’s about the only place it happens.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif">Does that help?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif">S<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<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"> ghc-devs [mailto:<a href="mailto:ghc-devs-bounces@haskell.org" target="_blank">ghc-devs-bounces@<wbr>haskell.org</a>]
<b>On Behalf Of </b>Conal Elliott<br>
<b>Sent:</b> 01 December 2016 21:51<br>
<b>To:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> How to inline early in a GHC plugin?<u></u><u></u></span></p>
</div>
</div><span class="">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
I'm implementing a GHC plugin that installs a `BuiltInRule` that does the work, and I'd like to learn how to inline more flexibly. Given an identifier `v`, I'm using `maybeUnfoldingTemplate (realIdUnfolding v)` to get a `Maybe CoreExpr`. Sometimes this recipe
yields `Nothing` until a later compiler phase. Meanwhile, I guess my variable `v` has been replaced by one with inlining info. First, am I understanding this mechanism correctly? A GHC source pointer to how inlining is made available would help me. Second,
can I access the inlining info before it's made available to the rest of the simplifier?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
Thanks, - Conal<u></u><u></u></p>
</div>
</div>
</span></div>
</div>
</div>
</blockquote></div><br></div>