Permalink
Browse files

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
  • Loading branch information...
1 parent 561a801 commit 8697d9a3de07f4a1b27dbbe4cc7104886e4c46bd Nicolas Frisby committed Mar 28, 2013
@@ -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)
@@ -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
@@ -0,0 +1,64 @@
+{-# LANGUAGE MagicHash #-}
+
+module T7796 where
+
+import GHC.Prim
+
+--
+-- test for #7796
+--
+-- created by nicolas.frisby@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
@@ -0,0 +1 @@
+0
@@ -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'])

0 comments on commit 8697d9a

Please sign in to comment.