Skip to content
Snippets Groups Projects
Commit 6c7fff0b authored by Simon Peyton Jones's avatar Simon Peyton Jones Committed by Marge Bot
Browse files

Eliminate unsafeEqualityProof in CorePrep

The main idea here is to avoid treating
  * case e of {}
  * case unsafeEqualityProof of UnsafeRefl co -> blah
specially in CoreToStg.  Instead, nail them in CorePrep,
by converting

   case e of {}
     ==>   e |> unsafe-co

   case unsafeEqualityProof of UnsafeRefl cv -> blah
     ==> blah[unsafe-co/cv]

in GHC.Core.Prep.  Now expressions that we want to treat as trivial
really are trivial.  We can get rid of cpExprIsTrivial.

And we fix #19700.

A downside is that, at least under unsafeEqualityProof, we substitute
in types and coercions, which is more work. But a big advantage is
that it's all very simple and principled: CorePrep really gets rid of
the unsafeCoerce stuff, as it does empty case, runRW#, lazyId etc.

I've updated the overview in GHC.Core.Prep, and added
  Note [Unsafe coercions] in GHC.Core.Prep
  Note [Implementing unsafeCoerce] in base:Unsafe.Coerce

We get 3% fewer bytes allocated when compiling perf/compiler/T5631,
which uses a lot of unsafeCoerces.  (It's a happy-generated parser.)

Metric Decrease:
    T5631
parent 06654a6e
No related branches found
No related tags found
No related merge requests found
Showing
with 418 additions and 222 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment