Add RubbishLit for absent bindings of UnliftedRep
authorSebastian Graf <sebastian.graf@kit.edu>
Sun, 14 Oct 2018 18:32:40 +0000 (20:32 +0200)
committerKrzysztof Gogolewski <krz.gogolewski@gmail.com>
Sun, 14 Oct 2018 18:32:41 +0000 (20:32 +0200)
commit448b77b93b369745e9bfbc8b46a5b87bb73dd379
tree8fd12e8698217f022651fe84a3ae9bf3d3e546a9
parent68a747c702d2432cc90d2a79a6aba0e67ac3e2c0
Add RubbishLit for absent bindings of UnliftedRep

Summary:
Trac #9279 reminded us that the worker wrapper transformation copes
really badly with absent unlifted boxed bindings.

As `Note [Absent errors]` in WwLib.hs points out, we can't just use
`absentError` for unlifted bindings because there is no bottom to hide
the error in.
So instead, we synthesise a new `RubbishLit` of type
`forall (a :: TYPE 'UnliftedRep). a`, which code-gen may subsitute for
any boxed value. We choose `()`, so that there is a good chance that
the program crashes instead instead of leading to corrupt data, should
absence analysis have been too optimistic (#11126).

Reviewers: simonpj, hvr, goldfire, bgamari, simonmar

Reviewed By: simonpj

Subscribers: osa1, rwbarton, carter

GHC Trac Issues: #15627, #9279, #4306, #11126

Differential Revision: https://phabricator.haskell.org/D5153
12 files changed:
compiler/basicTypes/Literal.hs
compiler/codeGen/StgCmmUtils.hs
compiler/coreSyn/CoreUtils.hs
compiler/ghci/ByteCodeAsm.hs
compiler/ghci/ByteCodeGen.hs
compiler/prelude/TysPrim.hs
compiler/prelude/TysWiredIn.hs
compiler/stgSyn/CoreToStg.hs
compiler/stranal/WwLib.hs
testsuite/tests/stranal/should_compile/T15627.hs [new file with mode: 0644]
testsuite/tests/stranal/should_compile/T15627.stderr [new file with mode: 0644]
testsuite/tests/stranal/should_compile/all.T