Cmm code of `id` function referring to `breakpoint`?

Shao, Cheng cheng.shao at tweag.io
Wed Feb 6 05:34:46 UTC 2019


Hi devs,

I just found that the Cmm code of `GHC.Base.id` refers to `breakpoint`
in the same module, however, in the Haskell source of `GHC.Base`, the
definition of `id` and `breakpoint` are totally unrelated:

```
id                      :: a -> a
id x                    =  x

breakpoint :: a -> a
breakpoint r = r
```

And here's the pretty-printed Cmm code:

```
base_GHCziBase_id_entry() //  [R2]
          { []
          }
      {offset
        chwa: // global
            R2 = R2;
            call base_GHCziBase_breakpoint_entry(R2) args: 8, res: 0, upd: 8;
      }
base_GHCziBase_breakpoint_entry() //  [R2]
          { []
          }
      {offset
        chvW: // global
            R1 = R2;
            call stg_ap_0_fast(R1) args: 8, res: 0, upd: 8;
      }
```

This looks suspicious. I'm curious if this is intended behavior of ghc.

Regards,
Shao Cheng


More information about the ghc-devs mailing list