[commit: ghc] ghc-8.0: Create empty dump files (fixes #10320) (1624fd9)
git at git.haskell.org
git at git.haskell.org
Thu Mar 24 22:00:11 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.0
Link : http://ghc.haskell.org/trac/ghc/changeset/1624fd9c108ff51fbb75eebaf7ead1786d99437c/ghc
>---------------------------------------------------------------
commit 1624fd9c108ff51fbb75eebaf7ead1786d99437c
Author: Kai Harries <kai.harries at gmail.com>
Date: Wed Mar 23 16:21:52 2016 +0100
Create empty dump files (fixes #10320)
Test Plan: ./validate
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2015
GHC Trac Issues: #10320
(cherry picked from commit 9f9345e5ad55e4a02e6de9afac814ac58c852ff2)
>---------------------------------------------------------------
1624fd9c108ff51fbb75eebaf7ead1786d99437c
compiler/simplCore/Simplify.hs | 14 +++++++++++++-
testsuite/tests/driver/Makefile | 8 ++++++++
testsuite/tests/driver/T10320.hs | 8 ++++++++
testsuite/tests/driver/all.T | 5 +++++
4 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/compiler/simplCore/Simplify.hs b/compiler/simplCore/Simplify.hs
index 5aa5881..ae44ee2 100644
--- a/compiler/simplCore/Simplify.hs
+++ b/compiler/simplCore/Simplify.hs
@@ -1581,7 +1581,9 @@ tryRules env rules fn args call_cont
= do { dflags <- getDynFlags
; case lookupRule dflags (getUnfoldingInRuleMatch env) (activeRule env)
fn (argInfoAppArgs args) rules of {
- Nothing -> return Nothing ; -- No rule matches
+ Nothing ->
+ do { nodump dflags -- This ensures that an empty file is written
+ ; return Nothing } ; -- No rule matches
Just (rule, rule_rhs) ->
do { checkedTick (RuleFired (ru_name rule))
; let cont' = pushSimplifiedArgs env
@@ -1606,6 +1608,16 @@ tryRules env rules fn args call_cont
| otherwise
= return ()
+ nodump dflags
+ | dopt Opt_D_dump_rule_rewrites dflags
+ = liftIO $ dumpSDoc dflags alwaysQualify Opt_D_dump_rule_rewrites "" empty
+
+ | dopt Opt_D_dump_rule_firings dflags
+ = liftIO $ dumpSDoc dflags alwaysQualify Opt_D_dump_rule_firings "" empty
+
+ | otherwise
+ = return ()
+
log_rule dflags flag hdr details
= liftIO . dumpSDoc dflags alwaysQualify flag "" $
sep [text hdr, nest 4 details]
diff --git a/testsuite/tests/driver/Makefile b/testsuite/tests/driver/Makefile
index 50696a7..8c98681 100644
--- a/testsuite/tests/driver/Makefile
+++ b/testsuite/tests/driver/Makefile
@@ -609,3 +609,11 @@ T10182:
"$(TEST_HC)" $(TEST_HC_OPTS) -c T10182.hs-boot
"$(TEST_HC)" $(TEST_HC_OPTS) -c T10182a.hs
"$(TEST_HC)" $(TEST_HC_OPTS) -c T10182.hs
+
+.PHONY: T10320
+T10320:
+ $(RM) -rf T10320 T10320.dump-rule-rewrites T10320.hi T10320.o
+ "$(TEST_HC)" $(TEST_HC_OPTS) -ddump-to-file -ddump-rule-rewrites -fenable-rewrite-rules T10320.hs
+ [ -s T10320.dump-rule-rewrites ]
+ "$(TEST_HC)" $(TEST_HC_OPTS) -ddump-to-file -ddump-rule-rewrites T10320.hs
+ [ -f T10320.dump-rule-rewrites ] && [ ! -s T10320.dump-rule-rewrites ]
diff --git a/testsuite/tests/driver/T10320.hs b/testsuite/tests/driver/T10320.hs
new file mode 100644
index 0000000..f2f613c
--- /dev/null
+++ b/testsuite/tests/driver/T10320.hs
@@ -0,0 +1,8 @@
+-- | Test file for issue #10320.
+
+module Main (main) where
+
+main :: IO ()
+main = print $ map (+1) (map (+1) [1, 2, 3])
+
+{-# RULES "map/map" forall f g xs. map f (map g xs) = map (f.g) xs #-}
diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T
index 5a19366..a50476a 100644
--- a/testsuite/tests/driver/all.T
+++ b/testsuite/tests/driver/all.T
@@ -471,3 +471,8 @@ test('T11429a', normal, compile, ['-Wunrecognised-warning-flags -Wfoobar'])
test('T11429b', normal, compile, ['-Wno-unrecognised-warning-flags -Wfoobar'])
test('T11429c', normal, compile_fail, ['-Wunrecognised-warning-flags -Werror -Wfoobar'])
+test('T10320',
+ [ ignore_output
+ , extra_clean(['T10320', 'T10320.o', 'T10320.hi'])],
+ run_command,
+ ['$MAKE -s --no-print-directory T10320'])
More information about the ghc-commits
mailing list