GHC.StgToCmm.Monad documentation out of sync?

Ben Gamari ben at
Mon Oct 18 23:59:41 UTC 2021

Norman Ramsey <nr at> writes:

> All,
> I'm looking at the paragraph starting on line 271 of GHC.StgToCmm.Monad,
> which purports to explain ReturnKind.  But the labels mentioned in the
> paragraph don't seem to match the preceding code example.  Also, I don't
> understand why only one branch of the `case` expression seems to
> be protected by a heap-limit check.
> I understand what I'm seeing well enough to fear that something is
> wrong, but not well enough to fix it.  Is someone else willing to
> have a look and maybe we can repair the documentation together?
Below is my understanding:

 * My suspicion here is that the paragraph starting on 271 would be clearer
   if it started with the word "However, ". That is, the preceding code
   snippet is what one would naively expect and the paragraph then explains
   what we would rather want the compiler to emit.

 * I also suspect that the reference to L4 should really read as L5.

 * The fact that there is only one heap check is likely merely for
   conciseness. The heap check shown is the check for the True branch.
   The code represented by "<False code>" would include its own heap
   check, but the author felt it was not important to list this
   explicitly since it was secondary to the message of the Note.

Does this seem reasonable to you?


- Ben

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 905 bytes
Desc: not available
URL: <>

More information about the ghc-devs mailing list