Less voluminous debug
authorsimonpj@microsoft.com <unknown>
Thu, 3 May 2007 12:47:15 +0000 (12:47 +0000)
committersimonpj@microsoft.com <unknown>
Thu, 3 May 2007 12:47:15 +0000 (12:47 +0000)
compiler/simplCore/CSE.lhs
compiler/simplCore/SimplUtils.lhs
compiler/specialise/Rules.lhs

index f8259c7..11eec3e 100644 (file)
@@ -19,6 +19,7 @@ import CoreSyn
 import VarEnv  
 import CoreLint                ( showPass, endPass )
 import Outputable
+import StaticFlags     ( opt_PprStyle_Debug )
 import BasicTypes      ( isAlwaysActive )
 import Util            ( mapAccumL, lengthExceeds )
 import UniqFM
@@ -314,13 +315,14 @@ addCSEnvItem env expr expr' | exprIsBig expr = env
 extendCSEnv (CS cs in_scope sub) expr expr'
   = CS (addToUFM_C combine cs hash [(expr, expr')]) in_scope sub
   where
-    hash   = hashExpr expr
-    combine old new = WARN( result `lengthExceeds` 4, ((text "extendCSEnv: long list (length" <+> int (length result) <> comma 
-                                                       <+> text "hash code" <+> text (show hash) <> char ')')
-                                                       $$ nest 4 (ppr result)) )
-                     result
-                   where
-                     result = new ++ old
+    hash = hashExpr expr
+    combine old new 
+       = WARN( result `lengthExceeds` 4, short_msg $$ nest 2 long_msg ) result
+       where
+         result = new ++ old
+         short_msg = ptext SLIT("extendCSEnv: long list, length") <+> int (length result)
+         long_msg | opt_PprStyle_Debug = (text "hash code" <+> text (show hash)) $$ ppr result 
+                  | otherwise          = empty
 
 lookupSubst (CS _ _ sub) x = case lookupVarEnv sub x of
                               Just y  -> y
index 9985397..5223fe0 100644 (file)
@@ -123,12 +123,12 @@ instance Outputable LetRhsFlag where
 
 instance Outputable SimplCont where
   ppr (Stop ty is_rhs _)            = ptext SLIT("Stop") <> brackets (ppr is_rhs) <+> ppr ty
-  ppr (ApplyTo dup arg se cont)      = ((ptext SLIT("ApplyTo") <+> ppr dup <+> pprParendExpr arg) $$ 
-                                         nest 2 (pprSimplEnv se)) $$ ppr cont
+  ppr (ApplyTo dup arg se cont)      = ((ptext SLIT("ApplyTo") <+> ppr dup <+> pprParendExpr arg)
+                                         {-  $$ nest 2 (pprSimplEnv se) -}) $$ ppr cont
   ppr (StrictBind b _ _ _ cont)      = (ptext SLIT("StrictBind") <+> ppr b) $$ ppr cont
   ppr (StrictArg f _ _ cont)         = (ptext SLIT("StrictArg") <+> ppr f) $$ ppr cont
   ppr (Select dup bndr alts se cont) = (ptext SLIT("Select") <+> ppr dup <+> ppr bndr) $$ 
-                                      (nest 4 (ppr alts $$ pprSimplEnv se)) $$ ppr cont
+                                      (nest 4 (ppr alts)) $$ ppr cont 
   ppr (CoerceIt co cont)            = (ptext SLIT("CoerceIt") <+> ppr co) $$ ppr cont
 
 data DupFlag = OkToDup | NoDup
index 758d60d..fb0ad40 100644 (file)
@@ -38,6 +38,7 @@ import Name           ( Name, NamedThing(..) )
 import NameEnv
 import Unify           ( ruleMatchTyX, MatchEnv(..) )
 import BasicTypes      ( Activation, CompilerPhase, isActive )
+import StaticFlags     ( opt_PprStyle_Debug )
 import Outputable
 import FastString
 import Maybes
@@ -258,10 +259,15 @@ findBest target (rule1,ans1) ((rule2,ans2):prs)
   | rule1 `isMoreSpecific` rule2 = findBest target (rule1,ans1) prs
   | rule2 `isMoreSpecific` rule1 = findBest target (rule2,ans2) prs
 #ifdef DEBUG
-  | otherwise = pprTrace "Rules.findBest: rule overlap (Rule 1 wins)"
-                        (vcat [ptext SLIT("Expression to match:") <+> ppr fn <+> sep (map ppr args),
-                               ptext SLIT("Rule 1:") <+> ppr rule1, 
-                               ptext SLIT("Rule 2:") <+> ppr rule2]) $
+  | otherwise = let pp_rule rule 
+                       | opt_PprStyle_Debug = ppr rule
+                       | otherwise          = doubleQuotes (ftext (ru_name rule))
+               in pprTrace "Rules.findBest: rule overlap (Rule 1 wins)"
+                        (vcat [if opt_PprStyle_Debug then 
+                                  ptext SLIT("Expression to match:") <+> ppr fn <+> sep (map ppr args)
+                               else empty,
+                               ptext SLIT("Rule 1:") <+> pp_rule rule1, 
+                               ptext SLIT("Rule 2:") <+> pp_rule rule2]) $
                findBest target (rule1,ans1) prs
 #else
   | otherwise = findBest target (rule1,ans1) prs