[commit: testsuite] master: new test for #7796, also improves a haddock perf (8697d9a)
Nicolas Frisby
nicolas.frisby at gmail.com
Thu Mar 28 18:28:25 CET 2013
Repository : ssh://darcs.haskell.org//srv/darcs/testsuite
On branch : master
https://github.com/ghc/testsuite/commit/8697d9a3de07f4a1b27dbbe4cc7104886e4c46bd
>---------------------------------------------------------------
commit 8697d9a3de07f4a1b27dbbe4cc7104886e4c46bd
Author: Nicolas Frisby <nicolas.frisby at gmail.com>
Date: Thu Mar 28 13:58:31 2013 +0000
new test for #7796, also improves a haddock perf
T149 is also an unexpected pass, but it's behaving
nondeterministically, so I'm not changing it for now
>---------------------------------------------------------------
tests/perf/haddock/all.T | 3 +-
tests/simplCore/should_compile/Makefile | 8 +++
tests/simplCore/should_compile/T7796.hs | 64 ++++++++++++++++++++
.../should_compile/T7796.stdout} | 0
tests/simplCore/should_compile/all.T | 4 +
5 files changed, 78 insertions(+), 1 deletions(-)
diff --git a/tests/perf/haddock/all.T b/tests/perf/haddock/all.T
index 6c59092..e094759 100644
--- a/tests/perf/haddock/all.T
+++ b/tests/perf/haddock/all.T
@@ -68,11 +68,12 @@ test('haddock.Cabal',
# 2012-08-14: 47461532 (x86/OSX)
# 2013-02-10: 46563344 (x86/OSX)
,stats_num_field('bytes allocated',
- [(wordsize(64), 3626604824, 2)
+ [(wordsize(64), 3517301864, 2)
# 2012-08-14: 3255435248 (amd64/Linux)
# 2012-08-29: 3324606664 (amd64/Linux, new codegen)
# 2012-10-08: 3373401360 (amd64/Linux)
# 2013-03-13: 3626604824 (amd64/Linux) Cabal updated
+ # 2013-03-28: 3517301864 (amd64/Linux) fixed #7796
,(platform('i386-unknown-mingw32'), 1906532680, 1)
# 2012-10-30: 1733638168 (x86/Windows)
# 2013-02-10: 1906532680 (x86/Windows)
diff --git a/tests/simplCore/should_compile/Makefile b/tests/simplCore/should_compile/Makefile
index a4fa8ad..215ed40 100644
--- a/tests/simplCore/should_compile/Makefile
+++ b/tests/simplCore/should_compile/Makefile
@@ -91,3 +91,11 @@ T7165:
T5366:
$(RM) -f T5366.hi T5366.o
'$(TEST_HC)' $(TEST_HC_OPTS) -ddump-simpl -dsuppress-uniques -c -O T5366.hs | grep 'Bar.*I#'
+
+# We expect 0 occurrences of ' $sgo' in -ddump-prep. Mind the Makefile
+# $-escaping. The -grep ignores grep's expected exit code of 1.
+.PHONY: T7796
+T7796:
+ '$(TEST_HC)' $(TEST_HC_OPTS) -O1 -c T7796.hs -ddump-prep > T7796.prep
+ (grep -q '$$w$$sgo' T7796.prep || echo 'could not find $$w$$sgo; compilation was not as expected')
+ -grep -c ' $$sgo' T7796.prep
diff --git a/tests/simplCore/should_compile/T7796.hs b/tests/simplCore/should_compile/T7796.hs
new file mode 100644
index 0000000..f0f5353
--- /dev/null
+++ b/tests/simplCore/should_compile/T7796.hs
@@ -0,0 +1,64 @@
+{-# LANGUAGE MagicHash #-}
+
+module T7796 where
+
+import GHC.Prim
+
+--
+-- test for #7796
+--
+-- created by nicolas.frisby at gmail.com, feel free to email me!
+--
+-- a delicate interaction between specialisation and w/w creates a
+-- binding that is dead but is allocated at run-time
+--
+
+--
+-- we grep the -ddump-prep for $s$go, and the actual test expects a
+-- particular number of hits
+--
+-- thus the test will fail in two scenarios:
+--
+-- * the actually interesting case where the zombie $s$go binding
+-- survives, or
+--
+-- * the naming convention for specialised things changes, in which
+-- case the Makefile rule for this test needs to be updated to
+-- scrape the -ddump-prep output differently
+--
+
+--
+-- the zombie binding is $sgo; here's how we reproduce it:
+--
+-- 1. specialise go such that the RHS of $sgo uses both $sgo and go
+--
+-- 2. worker-wrapper $sgo but *not* go
+--
+-- thus: $sgo uses $w$sgo uses go uses $sgo
+--
+-- the key point: the last "use" is only via a RULE; see the ticket
+-- #7796 for more discussion and related tickets
+--
+
+data L = C Int# L | N Int# -- I'm using unboxed elements to avoid ww'd
+ -- unrelated to the bug
+
+host :: Eq b => b -> L -> Bool
+host b x =
+ let go :: Eq a => -- must be used (to trigger specialise), but not
+ -- strict (else we ww the unspecialised version)
+
+ a -> -- must be strict, so that we ww the
+ -- specialisation
+
+ L -> -- not sure what this needs... but strict is
+ -- doing the trick
+
+ Bool
+
+ go d (N i) = d `seq` case i of
+ 0# -> True
+ o -> go b (N (i -# 1#)) -- NB must at (a ~ b)
+
+ go d (C x xs) = (d == d) `seq` go d (C (x -# 1#) xs)
+ in go (3 :: Int) x
diff --git a/tests/codeGen/should_run/T2838.stdout b/tests/simplCore/should_compile/T7796.stdout
similarity index 100%
copy from tests/codeGen/should_run/T2838.stdout
copy to tests/simplCore/should_compile/T7796.stdout
diff --git a/tests/simplCore/should_compile/all.T b/tests/simplCore/should_compile/all.T
index 570f295..f23061a 100644
--- a/tests/simplCore/should_compile/all.T
+++ b/tests/simplCore/should_compile/all.T
@@ -160,3 +160,7 @@ test('T5366',
normal,
run_command,
['$MAKE -s --no-print-directory T5366'])
+test('T7796',
+ extra_clean(['T7796.prep']),
+ run_command,
+ ['$MAKE -s --no-print-directory T7796'])
More information about the ghc-commits
mailing list