Ticket #12822: fix12822.patch

File fix12822.patch, 5.3 KB (added by captaintrunky, 16 months ago)

First implementation of unified verbosity flags.

  • compiler/main/DynFlags.hs

    From e4be4497f923fbd5d32e81f9f23b910c612b7e5e Mon Sep 17 00:00:00 2001
    From: Sergey Bykov <captaintrunky@gmail.com>
    Date: Sat, 14 Oct 2017 17:42:20 +0800
    Subject: [PATCH 1/3] First implementation of unified verbosity flags
    
    ---
     compiler/main/DynFlags.hs | 33 +++++++++++++++++++++++++++++++++
     1 file changed, 33 insertions(+)
    
    diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
    index 4c62a0d464..019f7d1439 100644
    a b data GeneralFlag 
    473473   | Opt_SolveConstantDicts
    474474   | Opt_CatchBottoms
    475475
     476   -- Verbosity flags
     477   | Opt_Verb0
     478   | Opt_Verb1
     479   | Opt_Verb2
     480   | Opt_Verb3
     481   | Opt_Verb4
     482
    476483   -- Interface files
    477484   | Opt_IgnoreInterfacePragmas
    478485   | Opt_OmitInterfacePragmas
    defaultFlags settings 
    40434050    ++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns]
    40444051             -- The default -O0 options
    40454052
     4053    ++ [f | (ns,f) <- verbLevelFlags, 0 `elem` ns]
     4054
    40464055    ++ default_PIC platform
    40474056
    40484057    ++ concatMap (wayGeneralFlags platform) (defaultWays settings)
    optLevelFlags -- see Note [Documenting optimisation flags] 
    41854194--   Static Argument Transformation needs investigation. See #9374
    41864195    ]
    41874196
     4197updVerbLevel :: Int -> DynFlags -> DynFlags
     4198-- ^ Sets the 'DynFlags' to be appropriate to the verbosity level
     4199updVerbLevel n dfs
     4200  = dfs2{ verbosity = final_n }
     4201  where
     4202   final_n = max 0 (min 6 n)    -- Clamp to 0 <= n <= 6
     4203   dfs1 = foldr (flip gopt_unset) dfs  remove_gopts
     4204   dfs2 = foldr (flip gopt_set)   dfs1 extra_gopts
     4205
     4206   extra_gopts  = [ f | (ns,f) <- verbLevelFlags, final_n `elem` ns ]
     4207   remove_gopts = [ f | (ns,f) <- verbLevelFlags, final_n `notElem` ns ]
     4208
     4209verbLevelFlags :: [([Int], GeneralFlag)]
     4210verbLevelFlags
     4211    = [ ([0], Opt_Verb0)
     4212      , ([1], Opt_Verb1)
     4213      , ([2], Opt_Verb2)
     4214      , ([3], Opt_Verb3)
     4215      , ([4], Opt_Verb4)
     4216      ]
     4217
    41884218{- Note [Eta-reduction in -O0]
    41894219~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    41904220Trac #11562 showed an example which tripped an ASSERT in CoreToStg; a
    setObjTarget l = updM set 
    48694899setOptLevel :: Int -> DynFlags -> DynP DynFlags
    48704900setOptLevel n dflags = return (updOptLevel n dflags)
    48714901
     4902setVerbLevel :: Int -> DynFlags -> DynP DynFlags
     4903setVerbLevel n dflags = return (updVerbLevel n dflags)
     4904
    48724905checkOptLevel :: Int -> DynFlags -> Either String DynFlags
    48734906checkOptLevel n dflags
    48744907   | hscTarget dflags == HscInterpreted && n > 0
  • compiler/main/DynFlags.hs

    -- 
    2.13.6
    
    
    From 5925c8392ee6bdb8f3ef68cb51c74000bd63907a Mon Sep 17 00:00:00 2001
    From: Sergey Bykov <captaintrunky@gmail.com>
    Date: Sat, 14 Oct 2017 17:57:16 +0800
    Subject: [PATCH 2/3] Minor refactoring
    
    ---
     compiler/main/DynFlags.hs | 8 ++++----
     1 file changed, 4 insertions(+), 4 deletions(-)
    
    diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
    index 019f7d1439..bc2cad84af 100644
    a b updVerbLevel n dfs 
    42094209verbLevelFlags :: [([Int], GeneralFlag)]
    42104210verbLevelFlags
    42114211    = [ ([0], Opt_Verb0)
    4212       , ([1], Opt_Verb1)
    4213       , ([2], Opt_Verb2)
    4214       , ([3], Opt_Verb3)
    4215       , ([4], Opt_Verb4)
     4212      , ([0, 1], Opt_Verb1)
     4213      , ([0, 1, 2], Opt_Verb2)
     4214      , ([0, 1, 2, 3], Opt_Verb3)
     4215      , ([0, 1, 2, 3, 4], Opt_Verb4)
    42164216      ]
    42174217
    42184218{- Note [Eta-reduction in -O0]
  • compiler/main/DynFlags.hs

    -- 
    2.13.6
    
    
    From 2ac9c7f2c400fca3baa8c1a17f8906689a1cf341 Mon Sep 17 00:00:00 2001
    From: Sergey Bykov <captaintrunky@gmail.com>
    Date: Sat, 14 Oct 2017 18:25:59 +0800
    Subject: [PATCH 3/3] Adding proper commentaries regarding #12822
    
    ---
     compiler/main/DynFlags.hs | 12 +++++++++---
     1 file changed, 9 insertions(+), 3 deletions(-)
    
    diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
    index bc2cad84af..b29de01a2f 100644
    a b data GeneralFlag 
    473473   | Opt_SolveConstantDicts
    474474   | Opt_CatchBottoms
    475475
    476    -- Verbosity flags
     476   -- Trac #12822 Cleanup GHC verbosity flags
     477   -- Predefined verbosity levels
    477478   | Opt_Verb0
    478479   | Opt_Verb1
    479480   | Opt_Verb2
    defaultFlags settings 
    40504051    ++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns]
    40514052             -- The default -O0 options
    40524053
     4054    -- Trac #12822 Cleanup GHC verbosity flags
    40534055    ++ [f | (ns,f) <- verbLevelFlags, 0 `elem` ns]
    40544056
    40554057    ++ default_PIC platform
    optLevelFlags -- see Note [Documenting optimisation flags] 
    41944196--   Static Argument Transformation needs investigation. See #9374
    41954197    ]
    41964198
     4199-- Trac #12822 Cleanup GHC verbosity flags
     4200-- Helpers to manage verbosity flags
     4201
    41974202updVerbLevel :: Int -> DynFlags -> DynFlags
    41984203-- ^ Sets the 'DynFlags' to be appropriate to the verbosity level
    41994204updVerbLevel n dfs
    verbLevelFlags 
    42154220      , ([0, 1, 2, 3, 4], Opt_Verb4)
    42164221      ]
    42174222
     4223setVerbLevel :: Int -> DynFlags -> DynP DynFlags
     4224setVerbLevel n dflags = return (updVerbLevel n dflags)
     4225
    42184226{- Note [Eta-reduction in -O0]
    42194227~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    42204228Trac #11562 showed an example which tripped an ASSERT in CoreToStg; a
    setObjTarget l = updM set 
    48994907setOptLevel :: Int -> DynFlags -> DynP DynFlags
    49004908setOptLevel n dflags = return (updOptLevel n dflags)
    49014909
    4902 setVerbLevel :: Int -> DynFlags -> DynP DynFlags
    4903 setVerbLevel n dflags = return (updVerbLevel n dflags)
    49044910
    49054911checkOptLevel :: Int -> DynFlags -> Either String DynFlags
    49064912checkOptLevel n dflags