How to disable the simple optimizer

Facundo Domínguez facundo.dominguez at tweag.io
Fri Jan 26 12:28:52 UTC 2024


Dear devs,

I noticed that GHC sometimes inlines bindings during desugaring, e.g

    foo = z
      where
            z  = z1 + z2
            z1 = 42
            z2 = 1

is desugared to

     foo = 42 + 1

This inlining is problematic when using a plugin like Liquid Haskell,
which wants to analyse in Core the local bindings provided by the
user.

Until ghc-9.6 LH didn't experience the inlining when using the GHC
API. And this is despite the fact that  using ghc from the command
line would seem to always inline during desugaring, even when using
-O0.

When using ghc-9.8.1 though, even the output of the GHC API started
having the bindings inlined. Some debugging with -ddump-ds and
-ddump-ds-preopt shows that inlining must be happening in the simple
optimizer.

Is there anything one could do to disable the optimizations?

Thanks in advance,
Facundo

-- 
All views and opinions expressed in this email message are the
personal opinions of the author and do not represent those of the
organization or its customers.


More information about the ghc-devs mailing list