<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)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
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-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
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:11.0pt;
font-family:"Calibri",sans-serif;}
p.Code, li.Code, div.Code
{mso-style-name:Code;
mso-style-link:"Code Char";
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:9.0pt;
font-family:"Courier New";}
span.CodeChar
{mso-style-name:"Code Char";
mso-style-link:Code;
font-family:"Courier New";}
span.m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-en
{mso-style-name:m_-8808691910045850736m_606611505207929420m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-en;}
span.m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-k
{mso-style-name:m_-8808691910045850736m_606611505207929420m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-k;}
span.m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-c1
{mso-style-name:m_-8808691910045850736m_606611505207929420m_46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-c1;}
span.EmailStyle24
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:941256686;
mso-list-template-ids:-1258659982;}
@list l1
{mso-list-id:2039698437;
mso-list-template-ids:247001316;}
@list l1:level1
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level2
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level3
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level4
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level5
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level6
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level7
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level8
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level9
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
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="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal" style="margin-left:36.0pt">Do unique names have SSA semantic in STG?<o:p></o:p></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">I’m not sure what you mean. STG just obeys normal lexical scoping.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:36.0pt">Can multiple (StgRec/StgNonRec) binding id have the same unique value?<o:p></o:p></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">No: the uniques are used during code generation to general labels that should be globally unique. At least I think this is so.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><br>
Simon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></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 <csaba.hruska@gmail.com>
<br>
<b>Sent:</b> 06 November 2018 18:30<br>
<b>To:</b> Simon Peyton Jones <simonpj@microsoft.com><br>
<b>Cc:</b> ghc-devs@haskell.org<br>
<b>Subject:</b> Re: StgRhsClosure freevar and argument name duplicates<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">I have a question.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Do unique names have SSA semantic in STG?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Can multiple (StgRec/StgNonRec) binding id have the same unique value?<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Tue, Nov 6, 2018 at 5:10 PM Csaba Hruska <<a href="mailto:csaba.hruska@gmail.com">csaba.hruska@gmail.com</a>> wrote:<o:p></o:p></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"><a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fghc.haskell.org%2Ftrac%2Fghc%2Fticket%2F15867&data=02%7C01%7Csimonpj%40microsoft.com%7C703e5403b6744e11468008d64415f230%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636771258392219504&sdata=g%2FNCmeBpaX0bHCttTveFxHTv%2BvIWaSbnH2V6uqNLwgQ%3D&reserved=0" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/15867</a><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Tue, Nov 6, 2018 at 4:47 PM Csaba Hruska <<a href="mailto:csaba.hruska@gmail.com" target="_blank">csaba.hruska@gmail.com</a>> wrote:<o:p></o:p></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>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Ok, I'll open a ticket.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">To reproduce:<o:p></o:p></p>
</div>
<div>
<ol start="1" type="1">
<li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1">
patch GHC head: <b><span style="font-family:"Courier New"">git apply StgScopeCheck.patch</span></b><o:p></o:p></li><li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1">
<span style="font-family:"Arial",sans-serif">make sure every compiled stg is linted:
<b>add -dstg-lint</b> to </span><span style="font-family:"Courier New"">GhcStage2HcOpts GhcLibHcOpts GhcRtsHcOpts config vars</span><o:p></o:p></li><li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo1">
<span style="font-family:"Courier New"">compile GHC HEAD</span><o:p></o:p></li></ol>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Tue, Nov 6, 2018 at 4:39 PM Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>> wrote:<o:p></o:p></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="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><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?</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt">thanks</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt">Simion</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt"> </span><o:p></o:p></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" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><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</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">You can reproduce the error with the GHC HEAD and with the attached patch for StgLinter.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">The patch adds scope checking for the linter.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">I've also attached the linter's error output against GHC HEAD.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">Compile GHC HEAD with the following settings:<o:p></o:p></p>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"><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><o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"><span style="font-family:"Courier New"">Regards,</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"><span style="font-family:"Courier New"">Csaba</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">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:<o:p></o:p></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;margin-bottom:6.0pt">Correction: I've also noticed that there are two Main.main top-level binders in the generated STG with different uniques.<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">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:<o:p></o:p></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;margin-bottom:6.0pt">I've also noticed that there are two Main.main top-level binders in the generated STG with different uniques?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">And GHC produces a working executable.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">Is Main.main an exception or does top-level names have some kind of "should be exported" property?<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">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:<o:p></o:p></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">I think top level names should be unique in occ-names; because those occ-names generate the symbols in the binary.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Simon<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></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" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><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><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">My plan is to extend GHC's STG linter to check the following properties:<o:p></o:p></p>
</div>
<div>
<ul type="disc">
<li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l1 level1 lfo2">
uniqueness of free var and arg list of StgRhsClosure<o:p></o:p></li><li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l1 level1 lfo2">
top level binding name uniqueness<o:p></o:p></li></ul>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I'll patch my local GHC 8.2.2 and GHC HEAD. I'll also attach the patch to the ticket.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I have a question regarding top level names.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Should the top-level names be unique as occ names or just in unique values?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">If not, then what is the rule?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Csaba<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">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:<o:p></o:p></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 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><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt">But I do wonder if it could perhaps be something to do with your branch?</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt">Thanks</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt">Simon</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt"> </span><o:p></o:p></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" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><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><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">Correction!<o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;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%7C703e5403b6744e11468008d64415f230%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636771258392219504&sdata=fYWWSsuuCoYVvrAGdqe1tIfE4Ju0eGYdTmiifMwYsCE%3D&reserved=0" target="_blank">https://github.com/ghc/ghc/blob/master/libraries/integer-gmp/src/GHC/Integer/Type.hs#L761-L770</a><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;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:<o:p></o:p></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="mso-margin-top-alt:auto;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%7C703e5403b6744e11468008d64415f230%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636771258392229512&sdata=gUF18l3YoI%2B45I1peceNAbUt0cS4SZguXmZYwFd0nLk%3D&reserved=0" target="_blank">
divModInteger</a> function from integer-simple GHC.Integer.Type.<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">The STG (GHC 8.2.2) generated from
<span class="m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-en">
<b>divModInteger</b></span><b> </b><span class="m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-k"><i>::</i></span><i>
<span class="m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-c1">
Integer</span> <span class="m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-k">
-></span> <span class="m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-c1">
Integer</span> <span class="m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-k">
-></span> (<span class="m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-k">#</span>
<span class="m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-c1">
Integer</span>, <span class="m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-c1">
Integer</span> <span class="m-8808691910045850736m606611505207929420m46499284808349707m-6968590000372433115m3531288177993350178m1605569262568664288m-5698606190592729368m5685414598476393737gmail-pl-k">
#</span>) </i>contains duplications in a closure binder list.<o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">Using my custom STG printer it looks like:<o:p></o:p></p>
</div>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"><span style="font-size:7.5pt;font-family:"Courier New"">module GHC.Integer.Type where</span><o:p></o:p></p>
</div>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
</div>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="mso-margin-top-alt:auto;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><o:p></o:p></p>
</div>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
</div>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="mso-margin-top-alt:auto;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%7C703e5403b6744e11468008d64415f230%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636771258392239516&sdata=8traO4EB6HSxRQe6gKzrQORLjuk32aMiDoPJxdju520%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%7C703e5403b6744e11468008d64415f230%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636771258392239516&sdata=8traO4EB6HSxRQe6gKzrQORLjuk32aMiDoPJxdju520%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><o:p></o:p></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;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:<o:p></o:p></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 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><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt">Simon</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt"> </span><o:p></o:p></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" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><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><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;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?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">This could explain my observations.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">And the scope checker function (addInScopeVars) does not check for duplicates.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">Any thoughts?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">Cheers,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">Csaba<o:p></o:p></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;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:<o:p></o:p></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="mso-margin-top-alt:auto;margin-bottom:6.0pt">Hi,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">Can StgRhsClosure's freevar list ([occ]) or argument list ([bndr]) contain duplicates?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">Cheers,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt">Csaba<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;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><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:6.0pt"> <o:p></o:p></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>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div>
</body>
</html>