diff options
author | Tobias Dammers <tdammers@gmail.com> | 2018-01-25 20:33:58 +0100 |
---|---|---|
committer | Tobias Dammers <tdammers@gmail.com> | 2018-04-20 10:33:00 +0200 |
commit | 03ed25a8f228c2f6d56793bc45f5709b9afb02c7 (patch) | |
tree | d8c706c85b1cc601215d11b623f35c7592ba7ef0 /compiler/coreSyn/CoreLint.hs | |
parent | 8f4ee8d5a349bc2395eafb4f45fd26e7f547f1d8 (diff) | |
download | haskell-wip/tdammers/D4394-squash.tar.gz |
Cache coercion roles in NthCowip/tdammers/D4394-squash
Most callers of mkNthCo know the role of the coercion they
are trying to make. So instead of calculating this role, we
pass it in, forcing the caller to calculate it when needed.
This introduces a performance regression in perf/compiler/T9872d.
Diffstat (limited to 'compiler/coreSyn/CoreLint.hs')
-rw-r--r-- | compiler/coreSyn/CoreLint.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs index 78902dfea4..af888b6fb0 100644 --- a/compiler/coreSyn/CoreLint.hs +++ b/compiler/coreSyn/CoreLint.hs @@ -1732,12 +1732,13 @@ lintCoercion co@(TransCo co1 co2) ; lintRole co r1 r2 ; return (k1a, k2b, ty1a, ty2b, r1) } -lintCoercion the_co@(NthCo n co) +lintCoercion the_co@(NthCo r0 n co) = do { (_, _, s, t, r) <- lintCoercion co ; case (splitForAllTy_maybe s, splitForAllTy_maybe t) of { (Just (tv_s, _ty_s), Just (tv_t, _ty_t)) | n == 0 - -> return (ks, kt, ts, tt, Nominal) + -> do { lintRole the_co Nominal r0 + ; return (ks, kt, ts, tt, r0) } where ts = tyVarKind tv_s tt = tyVarKind tv_t @@ -1751,7 +1752,8 @@ lintCoercion the_co@(NthCo n co) -- see Note [NthCo and newtypes] in TyCoRep , tys_s `equalLength` tys_t , tys_s `lengthExceeds` n - -> return (ks, kt, ts, tt, tr) + -> do { lintRole the_co tr r0 + ; return (ks, kt, ts, tt, r0) } where ts = getNth tys_s n tt = getNth tys_t n |