[Q] Inlining done: evtRead

Gabor Greif ggreif at gmail.com
Mon Jan 7 23:28:07 UTC 2019


Hi Simon,

a simplifier question...

Roughly a year ago I started learning about imported Ids, their unfoldings etc.

I have very small example program that compiles on Linux.

```haskell
import GHC.Event

main = print evtRead
```

`evtRead` is a newtype-wrapped Int. When you compile above program
with HEAD GHC without optimisation, you'll see that `evtRead` gets
passed directly to `show`.

But with -O1 it's unfolding will be inlined, floated to toplevel, and
dumped as static global data into the using Main module. This was not
the case in GHC 8.4. Not sure about 8.6 (will check). Anyway here is
the inlining notice that the simplifier gave me (-ddump-inlinings
-dverbose-core2core)

> Inlining done: GHC.Event.Internal.evtRead
>     Inlined fn:  (GHC.Types.I# 1#)
>                  `cast` (Sym (GHC.Event.Internal.N:Event[0])
>                          :: GHC.Types.Coercible GHC.Types.Int
> GHC.Event.Internal.Event)
>     Cont:   Stop[BoringCtxt] GHC.Event.Internal.Event
>

I believe this is a regression, as copies of global data can pop up in
potentially many different modules.

What do you think? Which change could have caused this?

Cheers,

    Gabor


More information about the ghc-devs mailing list