New flag: -ddump-strsigs
authorJoachim Breitner <mail@joachim-breitner.de>
Mon, 9 Dec 2013 15:29:21 +0000 (15:29 +0000)
committerJoachim Breitner <mail@joachim-breitner.de>
Mon, 9 Dec 2013 15:39:39 +0000 (15:39 +0000)
The existing flag -ddump-stranal dumps the full Core, which is very
verbose and not always helpful. This adds a more concise output (one
line per top-level bind) that is faster to read, and especially more
suitable to be used when writing test cases for the strictness analiser.

compiler/main/DynFlags.hs
compiler/stranal/DmdAnal.lhs
docs/users_guide/debugging.xml
docs/users_guide/flags.xml

index 05a72d6..70d2a81 100644 (file)
@@ -242,6 +242,7 @@ data DumpFlag
    | Opt_D_dump_prep
    | Opt_D_dump_stg
    | Opt_D_dump_stranal
+   | Opt_D_dump_strsigs
    | Opt_D_dump_tc
    | Opt_D_dump_types
    | Opt_D_dump_rules
@@ -2311,6 +2312,7 @@ dynamic_flags = [
   , Flag "ddump-prep"              (setDumpFlag Opt_D_dump_prep)
   , Flag "ddump-stg"               (setDumpFlag Opt_D_dump_stg)
   , Flag "ddump-stranal"           (setDumpFlag Opt_D_dump_stranal)
+  , Flag "ddump-strsigs"           (setDumpFlag Opt_D_dump_strsigs)
   , Flag "ddump-tc"                (setDumpFlag Opt_D_dump_tc)
   , Flag "ddump-types"             (setDumpFlag Opt_D_dump_types)
   , Flag "ddump-rules"             (setDumpFlag Opt_D_dump_rules)
index 99eb7ac..0ceb7c9 100644 (file)
@@ -35,6 +35,7 @@ import Util
 import Maybes          ( isJust, orElse )
 import TysWiredIn      ( unboxedPairDataCon )
 import TysPrim         ( realWorldStatePrimTy )
+import ErrUtils         ( dumpIfSet_dyn )
 \end{code}
 
 %************************************************************************
@@ -48,6 +49,8 @@ dmdAnalProgram :: DynFlags -> CoreProgram -> IO CoreProgram
 dmdAnalProgram dflags binds
   = do {
        let { binds_plus_dmds = do_prog binds } ;
+        dumpIfSet_dyn dflags Opt_D_dump_strsigs "Strictness signatures" $
+            dumpStrSig binds_plus_dmds ;
        return binds_plus_dmds
     }
   where
@@ -1100,6 +1103,15 @@ set_idDemandInfo env id dmd
 set_idStrictness :: AnalEnv -> Id -> StrictSig -> Id
 set_idStrictness env id sig
   = setIdStrictness id (zapStrictSig (ae_dflags env) sig)
+
+dumpStrSig :: CoreProgram -> SDoc
+dumpStrSig binds = vcat (concatMap goBind binds)
+  where
+  goBind (NonRec i _) = [ goId i ]
+  goBind (Rec bs)     = map (goId . fst) bs
+  goId id | isExportedId id = ppr id <> colon <+> pprIfaceStrictSig (idStrictness id)
+          | otherwise       = empty
+
 \end{code}
 
 Note [Initial CPR for strict binders]
index 003d2b5..5130345 100644 (file)
 
            <varlistentry>
              <term>
+               <option>-ddump-strsigs</option>:
+                <indexterm><primary><option>-ddump-strsigs</option></primary></indexterm>
+             </term>
+             <listitem>
+               <para>strictness signatures</para>
+             </listitem>
+           </varlistentry>
+
+           <varlistentry>
+             <term>
                <option>-ddump-cse</option>:
                 <indexterm><primary><option>-ddump-cse</option></primary></indexterm>
              </term>
index 72ef91e..2422b9d 100644 (file)
             <entry>-</entry>
           </row>
           <row>
+            <entry><option>-ddump-strsigs</option></entry>
+            <entry>Dump strictness signatures</entry>
+            <entry>dynamic</entry>
+            <entry>-</entry>
+          </row>
+          <row>
             <entry><option>-ddump-tc</option></entry>
             <entry>Dump typechecker output</entry>
             <entry>dynamic</entry>