[commit: ghc] master: Create empty dump files (fixes #10320) (9f9345e)

git at git.haskell.org git at git.haskell.org
Thu Mar 24 09:51:32 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/9f9345e5ad55e4a02e6de9afac814ac58c852ff2/ghc

>---------------------------------------------------------------

commit 9f9345e5ad55e4a02e6de9afac814ac58c852ff2
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


>---------------------------------------------------------------

9f9345e5ad55e4a02e6de9afac814ac58c852ff2
 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 e905300..debc7d8 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 e52eae3..ae75823 100644
--- a/testsuite/tests/driver/all.T
+++ b/testsuite/tests/driver/all.T
@@ -472,3 +472,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