summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2020-01-28 20:53:04 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-05-27 02:35:11 -0400
commit03d69e4bb6b92ccd8238bebd9cff68da23741f49 (patch)
tree4dbaf811ec9bda4c9544530f63509ad8c7062bc3 /testsuite
parent9faafb0aaff04e86a58b9e108f84618b12f2057c (diff)
downloadhaskell-03d69e4bb6b92ccd8238bebd9cff68da23741f49.tar.gz
Enable strict dicts by default at -O2.
In the common case this is a straight performance win at a compile time cost so we enable it at -O2. In rare cases it can lead to compile time regressions because of changed inlining behaviour. Which can very rarely also affect runtime performance. Increasing the inlining threshold can help to avoid this which is documented in the user guide. In terms of measured results this reduced instructions executed for nofib by 1%. However for some cases (e.g. Cabal) enabling this by default increases compile time by 2-3% so we enable it only at -O2 where it's clear that a user is willing to trade compile time for runtime. Most of the testsuite runs without -O2 so there are few perf changes. Increases: T12545/T18698: We perform more WW work because dicts are now treated strict. T9198: Also some more work because functions are now subject to W/W Decreases: T14697: Compiling empty modules. Probably because of changes inside ghc. T9203: I can't reproduce this improvement locally. Might be spurious. ------------------------- Metric Decrease: T12227 T14697 T9203 Metric Increase: T9198 T12545 T18698a T18698b -------------------------
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/warnings/should_compile/T16282/T16282.hs39
-rw-r--r--testsuite/tests/warnings/should_compile/T16282/T16282.stderr15
-rw-r--r--testsuite/tests/warnings/should_compile/T16282/T16282A.hs22
-rw-r--r--testsuite/tests/warnings/should_compile/T16282/all.T2
4 files changed, 57 insertions, 21 deletions
diff --git a/testsuite/tests/warnings/should_compile/T16282/T16282.hs b/testsuite/tests/warnings/should_compile/T16282/T16282.hs
index 0f6ab866a0..34abd24e51 100644
--- a/testsuite/tests/warnings/should_compile/T16282/T16282.hs
+++ b/testsuite/tests/warnings/should_compile/T16282/T16282.hs
@@ -1,14 +1,25 @@
-import Data.Map
-
--- If someone improves the specializer so that
--- GHC no longer misses the specialization below,
--- then this test will fail, as it expects a warning
--- to be issued.
--- Another reason this could fail is due to spelling:
--- the test checks for the "specialisation" spelling,
--- but due to changes in how the warnings are listed in DynFalgs.hs
--- the compiler may spit out the "specialization" spelling.
-main :: IO ()
-main = do
- let m = [] :: [Map String Bool]
- mapM_ print m
+{-# OPTIONS_GHC -Wall-missed-specialisations -O2 #-}
+
+import T16282A
+
+import Data.Map (Map)
+-- The purpose of this test is simple to trigger
+-- a missed specialization and check if GHC puts
+-- out a warning.
+-- It used to fail to specialize on the show instance
+-- for Data.Map, now that we enable -fdicts-strict by default
+-- the worker for these no longer take a dictionary (having been
+-- WWed). So instead we force it to fail to specialize on myMapM_
+
+-- If someone improves the specializer so that
+-- GHC no longer misses the specialization below,
+-- then this test will fail, as it expects a warning
+-- to be issued.
+-- Another reason this could fail is due to spelling:
+-- the test checks for the "specialisation" spelling,
+-- but due to changes in how the warnings are listed in DynFalgs.hs
+-- the compiler may spit out the "specialization" spelling.
+main :: IO ()
+main = do
+ let m = [] :: [MyMap Double]
+ myMapM_ print m
diff --git a/testsuite/tests/warnings/should_compile/T16282/T16282.stderr b/testsuite/tests/warnings/should_compile/T16282/T16282.stderr
index e9cc798546..b25c4c3563 100644
--- a/testsuite/tests/warnings/should_compile/T16282/T16282.stderr
+++ b/testsuite/tests/warnings/should_compile/T16282/T16282.stderr
@@ -1,10 +1,13 @@
+[1 of 2] Compiling T16282A ( T16282A.hs, T16282A.o )
+[2 of 2] Compiling Main ( T16282.hs, T16282.o )
T16282.hs: warning: [-Wall-missed-specialisations]
- Could not specialise imported function ‘Data.Foldable.$wmapM_’
- when specialising ‘mapM_’
- Probable fix: add INLINABLE pragma on ‘Data.Foldable.$wmapM_’
+ Could not specialise imported function ‘T16282A.$wmyMapM_’
+ when specialising ‘myMapM_’
+ Probable fix: add INLINABLE pragma on ‘T16282A.$wmyMapM_’
T16282.hs: warning: [-Wall-missed-specialisations]
- Could not specialise imported function ‘Data.Map.Internal.$w$cshowsPrec’
- when specialising ‘Data.Map.Internal.$fShowMap_$cshowsPrec’
- Probable fix: add INLINABLE pragma on ‘Data.Map.Internal.$w$cshowsPrec’
+ Could not specialise imported function ‘T16282A.$w$cshowsPrec’
+ when specialising ‘T16282A.$fShowMyMap_$cshowsPrec’
+ Probable fix: add INLINABLE pragma on ‘T16282A.$w$cshowsPrec’
+Linking T16282.exe ...
diff --git a/testsuite/tests/warnings/should_compile/T16282/T16282A.hs b/testsuite/tests/warnings/should_compile/T16282/T16282A.hs
new file mode 100644
index 0000000000..3bf6385fd0
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T16282/T16282A.hs
@@ -0,0 +1,22 @@
+-- To ensure we miss the mapM specialization we:
+-- * Prevent a unfolding with NOINLINE
+-- * Turn of dicts-strict, to keep a dictionary as argument.
+
+{-# OPTIONS_GHC -fno-dicts-strict #-}
+
+module T16282A where
+
+import Data.Map as M (Map, toList)
+
+newtype MyMap v = MyMap (Map Int v)
+
+instance (Show a) => Show (MyMap a) where
+ showsPrec d (MyMap m) = showParen (d > 10) $
+ showString "fromList " . shows (M.toList m)
+
+{-# NOINLINE myMapM_ #-}
+myMapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
+myMapM_ f = Prelude.foldr c (return ())
+ -- See Note [List fusion and continuations in 'c']
+ where c x k = f x >> k
+ {-# INLINE c #-}
diff --git a/testsuite/tests/warnings/should_compile/T16282/all.T b/testsuite/tests/warnings/should_compile/T16282/all.T
index dfcdd0562a..c3d2bf462a 100644
--- a/testsuite/tests/warnings/should_compile/T16282/all.T
+++ b/testsuite/tests/warnings/should_compile/T16282/all.T
@@ -1 +1 @@
-test('T16282', normal, compile, ['-O2 -Wall-missed-specialisations']) \ No newline at end of file
+test('T16282', [check_errmsg('-Wall-missed-specialisations')], multimod_compile, ['T16282', '-O2 -Wall-missed-specialisations'])