summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2020-10-21 17:25:44 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-11-13 14:29:39 -0500
commit63fa399726ff85a3ff4ca42a88f3d8a00921a718 (patch)
treeda61af959eb8ea74c1c7628a721443d137b0eb54 /testsuite
parent5353fd500b1e92636cd9d45274585fd88a915ff6 (diff)
downloadhaskell-63fa399726ff85a3ff4ca42a88f3d8a00921a718.tar.gz
Arity: Rework `ArityType` to fix monotonicity (#18870)
As we found out in #18870, `andArityType` is not monotone, with potentially severe consequences for termination of fixed-point iteration. That showed in an abundance of "Exciting arity" DEBUG messages that are emitted whenever we do more than one step in fixed-point iteration. The solution necessitates also recording `OneShotInfo` info for `ABot` arity type. Thus we get the following definition for `ArityType`: ``` data ArityType = AT [OneShotInfo] Divergence ``` The majority of changes in this patch are the result of refactoring use sites of `ArityType` to match the new definition. The regression test `T18870` asserts that we indeed don't emit any DEBUG output anymore for a function where we previously would have. Similarly, there's a regression test `T18937` for #18937, which we expect to be broken for now. Fixes #18870.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/arityanal/should_compile/T18870.hs12
-rw-r--r--testsuite/tests/arityanal/should_compile/T18937.hs8
-rw-r--r--testsuite/tests/arityanal/should_compile/all.T2
3 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/tests/arityanal/should_compile/T18870.hs b/testsuite/tests/arityanal/should_compile/T18870.hs
new file mode 100644
index 0000000000..b94fd13ffb
--- /dev/null
+++ b/testsuite/tests/arityanal/should_compile/T18870.hs
@@ -0,0 +1,12 @@
+{-# OPTIONS_GHC -O2 -fforce-recomp #-}
+
+module T18870 where
+
+import GHC.Exts
+
+-- This function should not lead to an "Exciting arity" DEBUG message.
+-- It should only do one round of fixed-point iteration to conclude that it has
+-- arity 2.
+f :: [a] -> a -> a
+f [] = id
+f (x:xs) = oneShot (\_ -> f xs x)
diff --git a/testsuite/tests/arityanal/should_compile/T18937.hs b/testsuite/tests/arityanal/should_compile/T18937.hs
new file mode 100644
index 0000000000..c7db70af02
--- /dev/null
+++ b/testsuite/tests/arityanal/should_compile/T18937.hs
@@ -0,0 +1,8 @@
+{-# OPTIONS_GHC -O2 -fforce-recomp #-}
+
+module T18937 where
+
+f :: [Int] -> Int -> Int
+f [] = id
+f (x:xs) = let y = sum [0..x]
+ in \z -> f xs (y + z)
diff --git a/testsuite/tests/arityanal/should_compile/all.T b/testsuite/tests/arityanal/should_compile/all.T
index 3413a3270c..60059b8e9c 100644
--- a/testsuite/tests/arityanal/should_compile/all.T
+++ b/testsuite/tests/arityanal/should_compile/all.T
@@ -19,3 +19,5 @@ test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn
# Regression tests
test('T18793', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques'])
+test('T18870', [ only_ways(['optasm']) ], compile, ['-ddebug-output'])
+test('T18937', [ only_ways(['optasm']), when(compiler_debugged(), expect_broken(18937)) ], compile, ['-ddebug-output'])