DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208)
In #23208 we observed that the demand signature of a binder occuring in a RULE wasn't unleashed, leading to a transitively used binder being discarded as absent. The solution was to use the same code path that we already use for handling exported bindings. See the changes to `Note [Absence analysis for stable unfoldings and RULES]` for more details. I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a `VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our existing framework. As a result, I had to touch quite a few places in the code. This refactoring exposed a few small bugs around correct handling of bottoming demand environments. As a result, some strictness signatures now mention uniques that weren't there before which caused test output changes to T13143, T19969 and T22112. But these tests compared whole -ddump-simpl listings which is a very fragile thing to begin with. I changed what exactly they test for based on the symptoms in the corresponding issues. There is a single regression in T18894 because we are more conservative around stable unfoldings now. Unfortunately it is not easily fixed; let's wait until there is a concrete motivation before invest more time. Fixes #23208.
Showing
- compiler/GHC/Core/Opt/DmdAnal.hs 124 additions, 85 deletionscompiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/SpecConstr.hs 8 additions, 7 deletionscompiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/CoreToStg/Prep.hs 1 addition, 1 deletioncompiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/Types/Demand.hs 174 additions, 162 deletionscompiler/GHC/Types/Demand.hs
- testsuite/tests/deSugar/should_compile/all.T 1 addition, 1 deletiontestsuite/tests/deSugar/should_compile/all.T
- testsuite/tests/simplCore/should_compile/all.T 2 additions, 2 deletionstestsuite/tests/simplCore/should_compile/all.T
- testsuite/tests/stranal/should_compile/T13143.hs 0 additions, 0 deletionstestsuite/tests/stranal/should_compile/T13143.hs
- testsuite/tests/stranal/should_compile/T13143.stderr 29 additions, 25 deletionstestsuite/tests/stranal/should_compile/T13143.stderr
- testsuite/tests/stranal/should_compile/T18894.stderr 107 additions, 73 deletionstestsuite/tests/stranal/should_compile/T18894.stderr
- testsuite/tests/stranal/should_compile/all.T 3 additions, 0 deletionstestsuite/tests/stranal/should_compile/all.T
- testsuite/tests/stranal/should_run/T23208.hs 4 additions, 0 deletionstestsuite/tests/stranal/should_run/T23208.hs
- testsuite/tests/stranal/should_run/T23208.stderr 3 additions, 0 deletionstestsuite/tests/stranal/should_run/T23208.stderr
- testsuite/tests/stranal/should_run/T23208_Lib.hs 12 additions, 0 deletionstestsuite/tests/stranal/should_run/T23208_Lib.hs
- testsuite/tests/stranal/should_run/all.T 1 addition, 0 deletionstestsuite/tests/stranal/should_run/all.T
Loading
Please register or sign in to comment