<div dir="ltr"><div>There's no need to set the srt field of f_info if f_closure is the SRT, since any reference to f_info in the code will give rise to a reference to f_closure in the SRT corresponding to that code fragment. Does that make sense?</div><div><br></div><div>The use of a closure as an SRT is really quite a nice optimisation actually.</div><div><br></div><div>Cheers</div><div>Simon<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 1 Jan 2020 at 09:35, Ömer Sinan Ağacan <<a href="mailto:omeragacan@gmail.com">omeragacan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Simon,<br>
<br>
In Cmm if I have a recursive group of functions f and g, and I'm using f's<br>
closure as the SRT for this group, should f's entry block's info table have<br>
f_closure as its SRT?<br>
<br>
In Cmm syntax<br>
<br>
     f_entry() {<br>
             { info_tbls: [...<br>
                           (c1vn,<br>
                            label: ...<br>
                            rep: ...<br>
                            srt: ??????]<br>
               stack_info: ...<br>
             }<br>
         {offset<br>
           c1vn:<br>
             ...<br>
         }<br>
     }<br>
<br>
Here should I have `f_closure` in the srt field?<br>
<br>
I'd expect yes, but looking at the current SRT code, in<br>
CmmBuildInfoTables.updInfoSRTs, we have this:<br>
<br>
  (newInfo, srtEntries) = case mapLookup (g_entry g) funSRTEnv of<br>
<br>
    Nothing -><br>
      -- if we don't add SRT entries to this closure, then we<br>
      -- want to set the srt field in its info table as usual<br>
      (info_tbl { cit_srt = mapLookup (g_entry g) srt_env }, [])<br>
<br>
    Just srtEntries -> srtTrace "maybeStaticFun" (ppr res)<br>
      (info_tbl { cit_rep = new_rep }, res)<br>
      where res = [ CmmLabel lbl | SRTEntry lbl <- srtEntries ]<br>
<br>
Here we only update SRT field of the block if we're not adding SRT entries to<br>
the function's closure, so in the example above, because we're using the<br>
function as SRT (and adding SRT entries to its closure) SRT field of c1vn won't<br>
be updated.<br>
<br>
Am I missing anything?<br>
<br>
Thanks,<br>
<br>
Ömer<br>
</blockquote></div>