diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2018-05-31 07:49:55 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-06-02 11:47:36 -0400 |
commit | f0c1eb8b5640b0ec86b9fabb465ea5b841808d56 (patch) | |
tree | 8cc92878ef62325536beaaba1594e9360a30c367 /compiler/stranal | |
parent | c983a1dbc01bb6ee68f67af5c7d662bc70845f6f (diff) | |
download | haskell-f0c1eb8b5640b0ec86b9fabb465ea5b841808d56.tar.gz |
Conservatively estimate levity in worker/wrapper
The worker/wrapper transform needs to determine the levity of the result to
determine whether it needs to introduce a lambda to preserve laziness of the
result. For this is previously used isUnliftedType. However, this may fail in
the presence of levity polymorphism.
We now instead use isLiftedType_maybe, assuming that a lambda is needed if the
levity of the result cannot be determined.
Fixes #15186.
Test Plan: make test=T15186
Reviewers: simonpj, goldfire, tdammers
Reviewed By: simonpj
Subscribers: rwbarton, thomie, carter
GHC Trac Issues: #15186
Differential Revision: https://phabricator.haskell.org/D4755
Diffstat (limited to 'compiler/stranal')
-rw-r--r-- | compiler/stranal/WwLib.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/stranal/WwLib.hs b/compiler/stranal/WwLib.hs index ab0a4d1ee1..040a6d7da9 100644 --- a/compiler/stranal/WwLib.hs +++ b/compiler/stranal/WwLib.hs @@ -269,11 +269,21 @@ mkWorkerArgs dflags args res_ty | otherwise = (args ++ [voidArgId], args ++ [voidPrimId]) where + -- See "Making wrapper args" section above needsAValueLambda = - isUnliftedType res_ty + lifted + -- We may encounter a levity-polymorphic result, in which case we + -- conservatively assume that we have laziness that needs preservation. + -- See #15186. || not (gopt Opt_FunToThunk dflags) -- see Note [Protecting the last value argument] + -- Might the result be lifted? + lifted = + case isLiftedType_maybe res_ty of + Just lifted -> lifted + Nothing -> True + {- Note [Protecting the last value argument] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |