Skip to content

WIP: [DO NOT MERGE] Refactor StgCmmExpr.cgCase, remove two bogus notes

Ömer Sinan Ağacan requested to merge osa1/ghc:refactor_cgCase into master

The notes were bogus:

  • "Dodgy unsafeCoerce 1": the note describes why we want to allow lifted-to-unlifted coercions, but we never really allowed this case. When the note was added the coercion check was implemented as

    reps_compatible = idPrimRep v == idPrimRep bndr

    which does not allow lifted-to-unlifted coercions.

  • "Dodgy unsafeCoerce 2": the note says that we sometimes generate

     case <lifted> of t :: unlifted { ... }

    for when the scrutinee is bottom, and we should generate a loop or panic. I think we don't generate such code, so the note and the relevant cgCase code is removed.

cgCase is updated so that in an expression like

case v of bndr { <prim alts> }

We no longer check whether v is unlifted or not, but we check, using CoreLint's coercion checking, that it's safe to coerce v to bndr.

This should unblock (!1381 (closed), #16893 (closed))

Edited by Ömer Sinan Ağacan

Merge request reports