<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">Hi Facundo</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Currently there is no way to disable the simple optimiser, but it would be easy to add a flag to do so.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">I'm not sure if that is really what you want -- you'll be left with a program with a lot of "junk" like (let x = y in ...). But maybe LH doesn't mind the junk!</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">If you decide that is what you want, I'm sure we (or you) can add a flag to control it. The relevant code is in GHC.HsToCore, below</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Before you go much further, do open a ticket.</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Simon</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">I think this the code you want to disable with a flag:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><span style="font-family:monospace"> ; let simpl_opts = initSimpleOpts dflags<br> ; let (ds_binds, ds_rules_for_imps, occ_anald_binds)<br> = simpleOptPgm simpl_opts mod final_pgm rules_for_imps<br> -- The simpleOptPgm gets rid of type<br> -- bindings plus any stupid dead code<br> ; putDumpFileMaybe logger Opt_D_dump_occur_anal "Occurrence analysis"<br> FormatCore (pprCoreBindings occ_anald_binds $$ pprRules ds_rules_for_imps )<br><br> ; endPassHscEnvIO </span>hsc_env name_ppr_ctx CoreDesugarOpt ds_binds ds_rules_for_imps<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 26 Jan 2024 at 12:29, Facundo Domínguez <<a href="mailto:facundo.dominguez@tweag.io">facundo.dominguez@tweag.io</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">Dear devs,<br>
<br>
I noticed that GHC sometimes inlines bindings during desugaring, e.g<br>
<br>
foo = z<br>
where<br>
z = z1 + z2<br>
z1 = 42<br>
z2 = 1<br>
<br>
is desugared to<br>
<br>
foo = 42 + 1<br>
<br>
This inlining is problematic when using a plugin like Liquid Haskell,<br>
which wants to analyse in Core the local bindings provided by the<br>
user.<br>
<br>
Until ghc-9.6 LH didn't experience the inlining when using the GHC<br>
API. And this is despite the fact that using ghc from the command<br>
line would seem to always inline during desugaring, even when using<br>
-O0.<br>
<br>
When using ghc-9.8.1 though, even the output of the GHC API started<br>
having the bindings inlined. Some debugging with -ddump-ds and<br>
-ddump-ds-preopt shows that inlining must be happening in the simple<br>
optimizer.<br>
<br>
Is there anything one could do to disable the optimizations?<br>
<br>
Thanks in advance,<br>
Facundo<br>
<br>
-- <br>
All views and opinions expressed in this email message are the<br>
personal opinions of the author and do not represent those of the<br>
organization or its customers.<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>