<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Ok, I'll open a ticket.</div><div>To reproduce:</div><div><ol><li>patch GHC head: <b><span style="font-family:monospace,monospace">git apply StgScopeCheck.patch</span></b></li><li><span style="font-family:monospace,monospace"><font face="arial,helvetica,sans-serif">make sure every compiled stg is linted: <b>add -dstg-lint</b> to </font><span style="font-family:monospace,monospace"></span><span style="font-family:monospace,monospace">GhcStage2HcOpts </span>GhcLibHcOpts GhcRtsHcOpts config vars</span></li><li><span style="font-family:monospace,monospace">compile GHC HEAD<br></span></li></ol></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 6, 2018 at 4:39 PM Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-GB" link="blue" vlink="purple">
<div class="m_46499284808349707WordSection1">
<p class="MsoNormal"><span style="font-size:12.0pt">can you open a Trac ticket, and explain how to reproduce it?  Does it require a patch, or does -ddump-stg show it?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">thanks<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Simion<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><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">From:</span></b><span lang="EN-US"> Csaba Hruska <<a href="mailto:csaba.hruska@gmail.com" target="_blank">csaba.hruska@gmail.com</a>>
<br>
<b>Sent:</b> 06 November 2018 15:36<br>
<b>To:</b> Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>><br>
<b>Cc:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Re: StgRhsClosure freevar and argument name duplicates<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
You can reproduce the error with the GHC HEAD and with the attached patch for StgLinter.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
The patch adds scope checking for the linter.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
I've also attached the linter's error output against GHC HEAD.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
Compile GHC HEAD with the following settings:<u></u><u></u></p>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<span style="font-family:"Courier New"">GhcStage1HcOpts=</span><br>
<span style="font-family:"Courier New"">GhcStage2HcOpts=-O2 -haddock -dstg-lint</span><br>
<span style="font-family:"Courier New"">GhcStage3HcOpts=-O2 -haddock -dstg-lint</span><u></u><u></u></p>
</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">
<span style="font-family:"Courier New"">Regards,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<span style="font-family:"Courier New"">Csaba</span><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>
</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">
On Tue, Nov 6, 2018 at 12:19 PM Csaba Hruska <<a href="mailto:csaba.hruska@gmail.com" target="_blank">csaba.hruska@gmail.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
Correction: I've also noticed that there are two Main.main top-level binders in the generated STG with different uniques.<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">
On Tue, Nov 6, 2018 at 12:19 PM Csaba Hruska <<a href="mailto:csaba.hruska@gmail.com" target="_blank">csaba.hruska@gmail.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
I've also noticed that there are two Main.main top-level binders in the generated STG with different uniques?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
And GHC produces a working executable.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
Is Main.main an exception or does top-level names have some kind of "should be exported" property?<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">
On Tue, Nov 6, 2018 at 12:02 PM Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">I think top level names should be unique in occ-names; because those occ-names generate the symbols in the binary.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Simon<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></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">From:</span></b><span lang="EN-US"> Csaba Hruska <<a href="mailto:csaba.hruska@gmail.com" target="_blank">csaba.hruska@gmail.com</a>>
<br>
<b>Sent:</b> 06 November 2018 11:01<br>
<b>To:</b> Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>><br>
<b>Cc:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Re: StgRhsClosure freevar and argument name duplicates</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">My plan is to extend GHC's STG linter to check the following properties:<u></u><u></u></p>
</div>
<div>
<ul type="disc">
<li class="MsoNormal">
uniqueness of free var and arg list of StgRhsClosure<u></u><u></u></li><li class="MsoNormal">
top level binding name uniqueness<u></u><u></u></li></ul>
</div>
<div>
<p class="MsoNormal">I'll patch my local GHC 8.2.2 and GHC HEAD. I'll also attach the patch to the ticket.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I have a question regarding top level names.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Should the top-level names be unique as occ names or just in unique values?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">If not, then what is the rule?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Csaba<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">On Tue, Nov 6, 2018 at 11:13 AM Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>> wrote:<u></u><u></u></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"><span style="font-size:12.0pt">Does this happen in HEAD with GHC’s own STG printer?  If so, could you file a Trac ticket – it’s clearly wrong.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt">But I do wonder if it could perhaps be something to do with your branch?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Thanks</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Simon</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><u></u><u></u></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">From:</span></b><span lang="EN-US"> Csaba Hruska <<a href="mailto:csaba.hruska@gmail.com" target="_blank">csaba.hruska@gmail.com</a>>
<br>
<b>Sent:</b> 05 November 2018 16:33<br>
<b>To:</b> Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>><br>
<b>Cc:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Re: StgRhsClosure freevar and argument name duplicates</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Correction!<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:6.0pt">The problem happens in integer-gmp:<br>
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fghc%2Fghc%2Fblob%2Fmaster%2Flibraries%2Finteger-gmp%2Fsrc%2FGHC%2FInteger%2FType.hs%23L761-L770&data=02%7C01%7Csimonpj%40microsoft.com%7C8ed5614402be4321be6908d643fda441%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636771154034475485&sdata=tglY4lglir%2FKqm3ApXo9gW4gHCWeRIBjP7UMEytNjxQ%3D&reserved=0" target="_blank">https://github.com/ghc/ghc/blob/master/libraries/integer-gmp/src/GHC/Integer/Type.hs#L761-L770</a><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">On Mon, Nov 5, 2018 at 5:27 PM Csaba Hruska <<a href="mailto:csaba.hruska@gmail.com" target="_blank">csaba.hruska@gmail.com</a>> wrote:<u></u><u></u></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>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">An example for the duplication please check the
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fghc%2Fghc%2Fblob%2Fmaster%2Flibraries%2Finteger-simple%2FGHC%2FInteger%2FType.hs%23L373-L380&data=02%7C01%7Csimonpj%40microsoft.com%7C8ed5614402be4321be6908d643fda441%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636771154034485494&sdata=6u7J6besY3OM9zfcr0x0LRuo7zJRphr6iHOq6xwO7mo%3D&reserved=0" target="_blank">
divModInteger</a> function from integer-simple GHC.Integer.Type.<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">The STG (GHC 8.2.2) generated from
<span class="m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-en">
<b>divModInteger</b></span><b> </b><span class="m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-k"><i>::</i></span><i>
<span class="m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-c1">
Integer</span> <span class="m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-k">
-></span> <span class="m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-c1">
Integer</span> <span class="m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-k">
-></span> (<span class="m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-k">#</span>
<span class="m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-c1">
Integer</span>, <span class="m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-c1">
Integer</span> <span class="m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-k">
#</span>) </i>contains duplications in a closure binder list.<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Using my custom STG printer it looks like:<u></u><u></u></p>
</div>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="margin-bottom:6.0pt"><span style="font-size:7.5pt;font-family:"Courier New"">module GHC.Integer.Type where</span><u></u><u></u></p>
</div>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="margin-bottom:6.0pt"><span style="font-size:7.5pt;font-family:"Courier New"">using GHC.Prim<br>
using GHC.Tuple<br>
using GHC.Types</span><u></u><u></u></p>
</div>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:7.5pt;font-family:"Courier New"">GHC.Integer.Type.divModInteger {-083-} =<br>
  closure (F:) (B:<br>
  n.s84123 {-s84123-}<br>
  d.s84124 {-s84124-}) {<br>
  case GHC.Integer.Type.quotRemInteger {-084-}<br>
         n.s84123 {-s84123-}<br>
         d.s84124 {-s84124-}<br>
  of qr.s84125 {-s84125-} {<br>
    GHC.Prim.(#,#) {-86-} ipv.s84126 {-s84126-} ipv1.s84127 {-s84127-} -><br>
      let $j.s84128 {-s84128-} =<br>
            closure (F:<br>
            d.s84124 {-s84124-}<br>
<b><span style="color:black;background:#f4cccc">            ipv.s84126 {-s84126-}</span></b><br>
<b><span style="color:black;background:#cfe2f3">            ipv1.s84127 {-s84127-}</span></b><br>
<b><span style="color:black;background:#f4cccc">            ipv.s84126 {-s84126-}</span></b><br>
<span style="color:black;background:#cfe2f3">            <b>ipv1.s84127 {-s84127-}</b></span><span style="color:black">) (B:</span><br>
            wild.s84129 {-s84129-}) {<br>
            let $j1.s84130 {-s84130-} =<br>
                  closure (F:<br>
                  d.s84124 {-s84124-}<br>
                  ipv.s84126 {-s84126-}<br>
                  ipv1.s84127 {-s84127-}<br>
                  ipv.s84126 {-s84126-}<br>
                  ipv1.s84127 {-s84127-}<br>
                  wild.s84129 {-s84129-}) (B:<br>
                  wild1.s84131 {-s84131-}) {<br>
                  case _stg_prim_negateInt#<br>
                         wild.s84129 {-s84129-}<br>
                  of sat.s84132 {-s84132-} {<br>
                    DEFAULT -><br>
                      case _stg_prim_==#<br>
                             wild1.s84131 {-s84131-}<br>
                             sat.s84132 {-s84132-}<br>
                      of sat.s84133 {-s84133-} {<br>
                        DEFAULT -><br>
                          case _stg_prim_tagToEnum#<br>
                                 sat.s84133 {-s84133-}<br>
                          of wild2.s84134 {-s84134-} {<br>
                            GHC.Types.False {-612-} -><br>
                              GHC.Prim.(#,#) {-86-}<br>
                                ipv.s84126 {-s84126-}<br>
                                ipv1.s84127 {-s84127-}<br>
                            GHC.Types.True {-645-} -><br>
                              case GHC.Integer.Type.plusInteger {-066-}<br>
                                     ipv1.s84127 {-s84127-}<br>
                                     d.s84124 {-s84124-}<br>
                              of r'.s84135 {-s84135-} {<br>
                                DEFAULT -><br>
                                  case GHC.Integer.Type.plusInteger {-066-}<br>
                                         ipv.s84126 {-s84126-}<br>
                                         GHC.Integer.Type.lvl11 {-r50574-}<br>
                                  of q'.s84136 {-s84136-} {<br>
                                    DEFAULT -><br>
                                      GHC.Prim.(#,#) {-86-}<br>
                                        q'.s84136 {-s84136-}<br>
                                        r'.s84135 {-s84135-}<br>
                                  }<br>
                              }<br>
                          }<br>
                      }<br>
                  }}<br>
                <br>
            in case ipv1.s84127 {-s84127-} <br>
               of wild1.s84137 {-s84137-} {<br>
                 GHC.Integer.Type.S# {-621-} i#.s84138 {-s84138-} -><br>
                   case _stg_prim_<#<br>
                          i#.s84138 {-s84138-} 0#<br>
                   of sat.s84140 {-s84140-} {<br>
                     DEFAULT -><br>
                       case _stg_prim_>#<br>
                              i#.s84138 {-s84138-} 0#<br>
                       of sat.s84139 {-s84139-} {<br>
                         DEFAULT -><br>
                           case _stg_prim_-#<br>
                                  sat.s84139 {-s84139-}<br>
                                  sat.s84140 {-s84140-}<br>
                           of sat.s84141 {-s84141-} {<br>
                             DEFAULT -><br>
                               $j1.s84130 {-s84130-}<br>
                                 sat.s84141 {-s84141-}<br>
                           }<br>
                       }<br>
                   }<br>
                 <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2FGHC.Integer.Type.Jp%23&data=02%7C01%7Csimonpj%40microsoft.com%7C8ed5614402be4321be6908d643fda441%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636771154034495502&sdata=2WLaJGm7NgH0FvibSDarfwBraI9nn0uAZVUH6CwaMno%3D&reserved=0" target="_blank">
GHC.Integer.Type.Jp#</a> {-r5813-} dt.s84142 {-s84142-} -><br>
                   $j1.s84130 {-s84130-} 1#<br>
                 GHC.Integer.Type.Jn# {-r5814-} dt.s84143 {-s84143-} -><br>
                   $j1.s84130 {-s84130-} -1#<br>
               }}<br>
          <br>
      in case d.s84124 {-s84124-} <br>
         of wild.s84144 {-s84144-} {<br>
           GHC.Integer.Type.S# {-621-} i#.s84145 {-s84145-} -><br>
             case _stg_prim_<#<br>
                    i#.s84145 {-s84145-} 0#<br>
             of sat.s84147 {-s84147-} {<br>
               DEFAULT -><br>
                 case _stg_prim_>#<br>
                        i#.s84145 {-s84145-} 0#<br>
                 of sat.s84146 {-s84146-} {<br>
                   DEFAULT -><br>
                     case _stg_prim_-#<br>
                            sat.s84146 {-s84146-}<br>
                            sat.s84147 {-s84147-}<br>
                     of sat.s84148 {-s84148-} {<br>
                       DEFAULT -><br>
                         $j.s84128 {-s84128-}<br>
                           sat.s84148 {-s84148-}<br>
                     }<br>
                 }<br>
             }<br>
           <a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2FGHC.Integer.Type.Jp%23&data=02%7C01%7Csimonpj%40microsoft.com%7C8ed5614402be4321be6908d643fda441%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636771154034495502&sdata=2WLaJGm7NgH0FvibSDarfwBraI9nn0uAZVUH6CwaMno%3D&reserved=0" target="_blank">
GHC.Integer.Type.Jp#</a> {-r5813-} dt.s84149 {-s84149-} -><br>
             $j.s84128 {-s84128-} 1#<br>
           GHC.Integer.Type.Jn# {-r5814-} dt.s84150 {-s84150-} -><br>
             $j.s84128 {-s84128-} -1#<br>
         }<br>
  }}</span><u></u><u></u></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">On Mon, Nov 5, 2018 at 2:08 PM Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>> wrote:<u></u><u></u></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"><span style="font-size:12.0pt">I don’t think there should be duplicates in either. Do you have a test case that shows duplicates?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Simon</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt"> </span><u></u><u></u></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">From:</span></b><span lang="EN-US"> ghc-devs <<a href="mailto:ghc-devs-bounces@haskell.org" target="_blank">ghc-devs-bounces@haskell.org</a>>
<b>On Behalf Of </b>Csaba Hruska<br>
<b>Sent:</b> 04 November 2018 11:22<br>
<b>To:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<b>Subject:</b> Re: StgRhsClosure freevar and argument name duplicates</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Is it possible that GHC generates STG with invalid binding semantics for certain cases that the Cmm codegen fix or ignore?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">This could explain my observations.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">I've checked the Stg linter source (StgLint.hs ; GHC 8.2.2 and github master) and it does not check StgRhsClosure free var and binder list at all.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">And the scope checker function (addInScopeVars) does not check for duplicates.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Any thoughts?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Cheers,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Csaba<u></u><u></u></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">On Sat, Nov 3, 2018 at 9:53 AM Csaba Hruska <<a href="mailto:csaba.hruska@gmail.com" target="_blank">csaba.hruska@gmail.com</a>> wrote:<u></u><u></u></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>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Hi,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Can StgRhsClosure's freevar list ([occ]) or argument list ([bndr]) contain duplicates?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Cheers,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt">Csaba<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"><span style="font-size:7.5pt;font-family:"Courier New"">data GenStgRhs bndr occ</span><br>
<span style="font-size:7.5pt;font-family:"Courier New"">  = StgRhsClosure</span><br>
<span style="font-size:7.5pt;font-family:"Courier New"">        CostCentreStack         -- CCS to be attached (default is CurrentCCS)</span><br>
<span style="font-size:7.5pt;font-family:"Courier New"">        StgBinderInfo           -- Info about how this binder is used (see below)</span><br>
<span style="font-size:7.5pt;font-family:"Courier New"">        <b>[occ]</b>                   -- non-global free vars; a list, rather than</span><br>
<span style="font-size:7.5pt;font-family:"Courier New"">                                -- a set, because order is important</span><br>
<span style="font-size:7.5pt;font-family:"Courier New"">        !UpdateFlag             -- ReEntrant | Updatable | SingleEntry</span><br>
<span style="font-size:7.5pt;font-family:"Courier New"">        <b>[bndr]</b>                  -- arguments; if empty, then not a function;</span><br>
<span style="font-size:7.5pt;font-family:"Courier New"">                                -- as above, order is important.</span><br>
<span style="font-size:7.5pt;font-family:"Courier New"">        (GenStgExpr bndr occ)   -- body</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:6.0pt"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div>
</div>

</blockquote></div>