Conservatively estimate levity in worker/wrapper
ClosedPublic

Authored by bgamari on May 30 2018, 4:58 PM.

Details

Summary

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 Trac #15186.

Test Plan

make test=T15186

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bgamari created this revision.May 30 2018, 4:58 PM
bgamari updated this revision to Diff 16597.May 30 2018, 5:04 PM

Unbreak test

simonpj accepted this revision.May 31 2018, 2:38 AM

Great!

compiler/stranal/WwLib.hs
276

It's Trac #15186!!!!

This revision is now accepted and ready to land.May 31 2018, 2:38 AM
tdammers requested changes to this revision.May 31 2018, 3:13 AM
This revision now requires changes to proceed.May 31 2018, 3:13 AM
tdammers added inline comments.May 31 2018, 3:15 AM
compiler/stranal/WwLib.hs
277

I believe this could be rewritten for clarity - the logic here seems a little convoluted.

Maybe something like:

needsAValueLambda =
    not (lifted && ftt_opt)
    where
        lifted = isLiftedType_maybe == Just True
        ftt_opt = gopt Opt_FunToThink dflags
bgamari updated this revision to Diff 16609.May 31 2018, 6:54 AM

Address comments

This revision was not accepted when it landed; it landed in state Needs Review.Jun 2 2018, 3:15 PM
This revision was automatically updated to reflect the committed changes.