multiple top level Main.main binders in STG

Csaba Hruska csaba.hruska at gmail.com
Fri Nov 2 21:50:27 UTC 2018


P.S.
I'd like to emphasize that this is produced by GHC and GHC's codegen
compiles it properly to a working executable.

On Fri, Nov 2, 2018 at 10:18 PM Csaba Hruska <csaba.hruska at gmail.com> wrote:

> Hello,
>
> I added an STG exporter to my modified GHC to do experiments with the STG
> representation of the program.
> I noticed that there are multiple top-level binders for *Main.main*
> function.
> Is this a convention or a bug?
>
> Regards,
> Csaba Hruska
>
> Here is an example code snippet of the exported STG of the Main module:
> Main.main2 =
>   closure (F:) (B:) {
>   case Main.$wupto 1# 10000000#
>   of sat.s16537 {
>     DEFAULT ->
>       case Main.$wxsum 0# sat.s16537
>       of ww.s16538 {
>         DEFAULT ->
>           case GHC.Show.$wshowSignedInt
>                  0# ww.s16538 GHC.Types.[]
>           of ww4.s16539 {
>             GHC.Prim.(#,#) ww5.s16540 ww6.s16541 ->
>               GHC.Types.:
>                 ww5.s16540 ww6.s16541
>           }
>       }
>   }}
>
> Main.main1 =
>   closure (F:) (B: void.040) {
>   GHC.IO.Handle.Text.hPutStr2
>     GHC.IO.Handle.FD.stdout
>     Main.main2
>     GHC.Types.True
>     GHC.Prim.void#}
>
> *Main.main* =
>   closure (F:) (B: void.040) {
>   Main.main1 GHC.Prim.void#}
>
> Main.main3 =
>   closure (F:) (B: void.040) {
>   GHC.TopHandler.runMainIO1
>     Main.main1 GHC.Prim.void#}
>
> *Main.main* =
>   closure (F:) (B: void.040) {
>   Main.main3 GHC.Prim.void#}
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20181102/566df396/attachment.html>


More information about the ghc-devs mailing list