diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2021-05-14 12:24:48 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-19 23:37:44 -0400 |
commit | e87b8e108303634af8a7247037d50ab10456c189 (patch) | |
tree | 5a04dd51a99d6b08fead5ebc01b70cc213d57dc2 /testsuite | |
parent | 6844ead4f45620f0e9573762e9a892d1ae1609f4 (diff) | |
download | haskell-e87b8e108303634af8a7247037d50ab10456c189.tar.gz |
CPR: Detect constructed products in `runRW#` apps (#19822)
In #19822, we realised that the Simplifier's new habit of floating cases into
`runRW#` continuations inhibits CPR analysis from giving key functions of `text`
the CPR property, such as `singleton`.
This patch fixes that by anticipating part of !5667 (Nested CPR) to give
`runRW#` the proper CPR transformer it now deserves: Namely, `runRW# (\s -> e)`
should have the CPR property iff `e` has it.
The details are in `Note [Simplification of runRW#]` in GHC.CoreToStg.Prep.
The output of T18086 changed a bit: `panic` (which calls `runRW#`) now has
`botCpr`. As outlined in Note [Bottom CPR iff Dead-Ending Divergence], that's
OK.
Fixes #19822.
Metric Decrease:
T9872d
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/cpranal/sigs/T19822.hs | 14 | ||||
-rw-r--r-- | testsuite/tests/cpranal/sigs/T19822.stderr | 5 | ||||
-rw-r--r-- | testsuite/tests/cpranal/sigs/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/T18086.stderr | 2 |
4 files changed, 21 insertions, 1 deletions
diff --git a/testsuite/tests/cpranal/sigs/T19822.hs b/testsuite/tests/cpranal/sigs/T19822.hs new file mode 100644 index 0000000000..ca83bafcc3 --- /dev/null +++ b/testsuite/tests/cpranal/sigs/T19822.hs @@ -0,0 +1,14 @@ +{-# OPTIONS_GHC -O2 -fforce-recomp #-} +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +module T19822 where + +import GHC.Exts +import Data.Char + +data Text = MkText !Int Char + +-- | Should have the CPR property +singleton :: Char -> Text +singleton c = MkText (runRW# (\_ -> 42 + ord c)) c +{-# NOINLINE singleton #-} -- to force WW diff --git a/testsuite/tests/cpranal/sigs/T19822.stderr b/testsuite/tests/cpranal/sigs/T19822.stderr new file mode 100644 index 0000000000..8e4636d322 --- /dev/null +++ b/testsuite/tests/cpranal/sigs/T19822.stderr @@ -0,0 +1,5 @@ + +==================== Cpr signatures ==================== +T19822.singleton: 1 + + diff --git a/testsuite/tests/cpranal/sigs/all.T b/testsuite/tests/cpranal/sigs/all.T index 0647c8a611..99cdebe716 100644 --- a/testsuite/tests/cpranal/sigs/all.T +++ b/testsuite/tests/cpranal/sigs/all.T @@ -8,3 +8,4 @@ setTestOpts(extra_hc_opts('-dno-typeable-binds -ddump-cpr-signatures')) test('CaseBinderCPR', normal, compile, ['']) test('T19232', normal, compile, ['']) test('T19398', normal, compile, ['']) +test('T19822', normal, compile, ['']) diff --git a/testsuite/tests/stranal/sigs/T18086.stderr b/testsuite/tests/stranal/sigs/T18086.stderr index 43266ad0da..1748a0c145 100644 --- a/testsuite/tests/stranal/sigs/T18086.stderr +++ b/testsuite/tests/stranal/sigs/T18086.stderr @@ -9,7 +9,7 @@ T18086.panic: <L>x ==================== Cpr signatures ==================== T18086.$trModule: T18086.m: b -T18086.panic: +T18086.panic: b |