[Git][ghc/ghc][master] Do primop rep-poly checks when instantiating
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Tue Jul 18 10:37:58 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
889c2bbb by sheaf at 2023-07-18T06:37:32-04:00
Do primop rep-poly checks when instantiating
This patch changes how we perform representation-polymorphism checking
for primops (and other wired-in Ids such as coerce).
When instantiating the primop, we check whether each type variable
is required to instantiated to a concrete type, and if so we create a
new concrete metavariable (a ConcreteTv) instead of a simple MetaTv.
(A little subtlety is the need to apply the substitution obtained from
instantiating to the ConcreteTvOrigins, see
Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.)
This allows us to prevent representation-polymorphism in non-argument
position, as that is required for some of these primops.
We can also remove the logic in tcRemainingValArgs, except for
the part concerning representation-polymorphic unlifted newtypes.
The function has been renamed rejectRepPolyNewtypes; all it does now
is reject unsaturated occurrences of representation-polymorphic newtype
constructors when the representation of its argument isn't a concrete
RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check).
The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head
gives more explanation about a possible path to PHASE 2, which would be
in line with the treatment for primops taken in this patch.
We also update the Core Lint check to handle this new framework. This
means Core Lint now checks representation-polymorphism in continuation
position like needed for catch#.
Fixes #21906
-------------------------
Metric Increase:
LargeRecord
-------------------------
- - - - -
27 changed files:
- compiler/GHC/Builtin/PrimOps.hs
- compiler/GHC/Builtin/PrimOps/Ids.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/Core.hs
- compiler/GHC/Core/DataCon.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/TyCo/Subst.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Driver/Config/Core/Lint.hs
- compiler/GHC/HsToCore.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Tc/TyCl/Build.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Types/Origin.hs-boot
- compiler/GHC/Tc/Utils/Concrete.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Utils/TcType.hs
- compiler/GHC/Tc/Utils/TcType.hs-boot
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/889c2bbb06e8bd9193a4f5fbe8633593405b52d2
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/889c2bbb06e8bd9193a4f5fbe8633593405b52d2
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230718/acb9de89/attachment-0001.html>
More information about the ghc-commits
mailing list