[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: No need for CURSES_INCLUDE_DIRS

Marge Bot gitlab at gitlab.haskell.org
Fri Jul 3 00:39:27 UTC 2020



 Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
4d90b3ff by Gabor Greif at 2020-07-02T20:07:59-04:00
No need for CURSES_INCLUDE_DIRS

This is a leftover from ef63ff27251a20ff11e58c9303677fa31e609a88
- - - - -
f08d6316 by Sylvain Henry at 2020-07-02T20:08:36-04:00
Replace Opt_SccProfilingOn flag with sccProfilingEnabled helper function

SCC profiling was enabled in a convoluted way: if WayProf was enabled,
Opt_SccProfilingOn general flag was set (in
`GHC.Driver.Ways.wayGeneralFlags`), and then this flag was queried in
various places.

There is no need to go via general flags, so this patch defines a
`sccProfilingEnabled :: DynFlags -> Bool` helper function that just
checks whether WayProf is enabled.

- - - - -
06d2baee by Ben Gamari at 2020-07-02T20:39:20-04:00
rts/ProfHeap: Only allocate the Censuses that we need

When not LDV profiling there is no reason to allocate 32 Censuses; one
will do. This is a very small memory footprint optimisation, but it
comes for free.

- - - - -
5b971f91 by Ben Gamari at 2020-07-02T20:39:20-04:00
rts/ProfHeap: Free old allocations when reinitialising Censuses

Previously when not LDV profiling we would repeatedly reinitialise
`censuses[0]` with `initEra`. This failed to free the `Arena` and
`HashTable` from the old census, resulting in a memory leak.

Fixes #18348.

- - - - -
126686e5 by Valery Tolstov at 2020-07-02T20:39:20-04:00
Mention flags that are not enabled by -Wall (#18372)

* Mention missing flags that are not actually enabled by -Wall (docs/users_guide/using-warnings.rst)
* Additionally remove -Wmissing-monadfail-instances from the list of flags enabled by -Wcompat, as it is not the case since 8.8

- - - - -
9e8fa44a by Sylvain Henry at 2020-07-02T20:39:22-04:00
LLVM: support R9 and R10 registers

d535ef006d85dbdb7cda2b09c5bc35cb80108909 allowed the use of up to 10
vanilla registers but didn't update LLVM backend to support them. This
patch fixes it.

- - - - -


23 changed files:

- aclocal.m4
- compiler/GHC.hs
- compiler/GHC/Cmm/Info.hs
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/CmmToLlvm/Regs.hs
- compiler/GHC/Driver/CodeOutput.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Driver/Ways.hs
- compiler/GHC/HsToCore/Coverage.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/Iface/Recomp/Flags.hs
- compiler/GHC/Runtime/Heap/Layout.hs
- compiler/GHC/Stg/Syntax.hs
- compiler/GHC/StgToCmm/Bind.hs
- compiler/GHC/StgToCmm/Closure.hs
- compiler/GHC/StgToCmm/Foreign.hs
- compiler/GHC/StgToCmm/Layout.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/StgToCmm/Prof.hs
- docs/users_guide/using-warnings.rst
- rts/ProfHeap.c


Changes:

=====================================
aclocal.m4
=====================================
@@ -1875,7 +1875,6 @@ AC_DEFUN([FP_CURSES],
       [directory containing curses libraries])],
       [CURSES_LIB_DIRS=$withval])
 
-  AC_SUBST(CURSES_INCLUDE_DIRS)
   AC_SUBST(CURSES_LIB_DIRS)
 ])# FP_CURSES
 


=====================================
compiler/GHC.hs
=====================================
@@ -605,10 +605,12 @@ setSessionDynFlags dflags = do
     then do
          let
            prog = pgm_i dflags ++ flavour
+           profiled = ways dflags `hasWay` WayProf
+           dynamic  = ways dflags `hasWay` WayDyn
            flavour
-             | WayProf `S.member` ways dflags = "-prof"
-             | WayDyn `S.member` ways dflags  = "-dyn"
-             | otherwise                      = ""
+             | profiled  = "-prof" -- FIXME: can't we have both?
+             | dynamic   = "-dyn"
+             | otherwise = ""
            msg = text "Starting " <> text prog
          tr <- if verbosity dflags >= 3
                 then return (logInfo dflags $ withPprStyle defaultDumpStyle msg)
@@ -617,8 +619,8 @@ setSessionDynFlags dflags = do
           conf = IServConfig
             { iservConfProgram  = prog
             , iservConfOpts     = getOpts dflags opt_i
-            , iservConfProfiled = gopt Opt_SccProfilingOn dflags
-            , iservConfDynamic  = WayDyn `S.member` ways dflags
+            , iservConfProfiled = profiled
+            , iservConfDynamic  = dynamic
             , iservConfHook     = createIservProcessHook (hooks dflags)
             , iservConfTrace    = tr
             }


=====================================
compiler/GHC/Cmm/Info.hs
=====================================
@@ -405,7 +405,7 @@ mkStdInfoTable dflags (type_descr, closure_descr) cl_type srt layout_lit
  where
     platform = targetPlatform dflags
     prof_info
-        | gopt Opt_SccProfilingOn dflags = [type_descr, closure_descr]
+        | sccProfilingEnabled dflags = [type_descr, closure_descr]
         | otherwise = []
 
     tag = CmmInt (fromIntegral cl_type) (halfWordWidth platform)
@@ -565,7 +565,7 @@ stdInfoTableSizeW :: DynFlags -> WordOff
 -- It must vary in sync with mkStdInfoTable
 stdInfoTableSizeW dflags
   = fixedInfoTableSizeW
-  + if gopt Opt_SccProfilingOn dflags
+  + if sccProfilingEnabled dflags
        then profInfoTableSizeW
        else 0
 


=====================================
compiler/GHC/Cmm/Parser.y
=====================================
@@ -1168,7 +1168,7 @@ reserveStackFrame psize preg body = do
   withUpdFrameOff frame body
 
 profilingInfo dflags desc_str ty_str
-  = if not (gopt Opt_SccProfilingOn dflags)
+  = if not (sccProfilingEnabled dflags)
     then NoProfilingInfo
     else ProfilingInfo (BS8.pack desc_str) (BS8.pack ty_str)
 


=====================================
compiler/GHC/CmmToLlvm/Regs.hs
=====================================
@@ -47,6 +47,8 @@ lmGlobalReg platform suf reg
         VanillaReg 6 _ -> wordGlobal $ "R6" ++ suf
         VanillaReg 7 _ -> wordGlobal $ "R7" ++ suf
         VanillaReg 8 _ -> wordGlobal $ "R8" ++ suf
+        VanillaReg 9 _ -> wordGlobal $ "R9" ++ suf
+        VanillaReg 10 _ -> wordGlobal $ "R10" ++ suf
         SpLim          -> wordGlobal $ "SpLim" ++ suf
         FloatReg 1     -> floatGlobal $"F1" ++ suf
         FloatReg 2     -> floatGlobal $"F2" ++ suf


=====================================
compiler/GHC/Driver/CodeOutput.hs
=====================================
@@ -275,11 +275,9 @@ outputForeignStubs_help fname doc_str header footer
 -- module;
 
 -- | Generate code to initialise cost centres
-profilingInitCode :: DynFlags -> Module -> CollectedCCs -> SDoc
-profilingInitCode dflags this_mod (local_CCs, singleton_CCSs)
- = if not (gopt Opt_SccProfilingOn dflags)
-   then empty
-   else vcat
+profilingInitCode :: Module -> CollectedCCs -> SDoc
+profilingInitCode this_mod (local_CCs, singleton_CCSs)
+ = vcat
     $  map emit_cc_decl local_CCs
     ++ map emit_ccs_decl singleton_CCSs
     ++ [emit_cc_list local_CCs]


=====================================
compiler/GHC/Driver/Flags.hs
=====================================
@@ -252,7 +252,6 @@ data GeneralFlag
    | Opt_PIE                         -- ^ @-fPIE@
    | Opt_PICExecutable               -- ^ @-pie@
    | Opt_ExternalDynamicRefs
-   | Opt_SccProfilingOn
    | Opt_Ticky
    | Opt_Ticky_Allocd
    | Opt_Ticky_LNE


=====================================
compiler/GHC/Driver/Main.hs
=====================================
@@ -1412,7 +1412,9 @@ hscGenHardCode hsc_env cgguts location output_filename = do
 
         let cost_centre_info =
               (S.toList local_ccs ++ caf_ccs, caf_cc_stacks)
-            prof_init = profilingInitCode dflags this_mod cost_centre_info
+            prof_init
+               | sccProfilingEnabled dflags = profilingInitCode this_mod cost_centre_info
+               | otherwise = empty
             foreign_stubs = foreign_stubs0 `appendStubC` prof_init
 
         ------------------  Code generation ------------------


=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -42,6 +42,7 @@ module GHC.Driver.Session (
         whenCannotGenerateDynamicToo,
         dynamicTooMkDynamicDynFlags,
         dynamicOutputFile,
+        sccProfilingEnabled,
         DynFlags(..),
         FlagSpec(..),
         HasDynFlags(..), ContainsDynFlags(..),
@@ -5094,6 +5095,10 @@ isBmi2Enabled dflags = case platformArch (targetPlatform dflags) of
     ArchX86    -> bmiVersion dflags >= Just BMI2
     _          -> False
 
+-- | Indicate if cost-centre profiling is enabled
+sccProfilingEnabled :: DynFlags -> Bool
+sccProfilingEnabled dflags = ways dflags `hasWay` WayProf
+
 -- -----------------------------------------------------------------------------
 -- Linker/compiler information
 


=====================================
compiler/GHC/Driver/Ways.hs
=====================================
@@ -20,6 +20,7 @@
 -- this compilation.
 module GHC.Driver.Ways
    ( Way(..)
+   , hasWay
    , allowed_combination
    , wayGeneralFlags
    , wayUnsetGeneralFlags
@@ -60,12 +61,15 @@ data Way
   | WayDyn           -- ^ Dynamic linking
   deriving (Eq, Ord, Show)
 
+-- | Test if a ways is enabled
+hasWay :: Set Way -> Way -> Bool
+hasWay ws w = Set.member w ws
 
 -- | Check if a combination of ways is allowed
 allowed_combination :: Set Way -> Bool
 allowed_combination ways = not disallowed
   where
-   disallowed = or [ Set.member ways x && Set.member ways y
+   disallowed = or [ hasWay ways x && hasWay ways y
                    | (x,y) <- couples
                    ]
    -- List of disallowed couples of ways
@@ -121,7 +125,7 @@ wayGeneralFlags _ WayDyn      = [Opt_PIC, Opt_ExternalDynamicRefs]
     -- .so before loading the .so using the system linker.  Since only
     -- PIC objects can be linked into a .so, we have to compile even
     -- modules of the main program with -fPIC when using -dynamic.
-wayGeneralFlags _ WayProf     = [Opt_SccProfilingOn]
+wayGeneralFlags _ WayProf     = []
 wayGeneralFlags _ WayEventLog = []
 
 -- | Turn these flags off when enabling this way


=====================================
compiler/GHC/HsToCore/Coverage.hs
=====================================
@@ -1040,7 +1040,7 @@ coveragePasses :: DynFlags -> [TickishType]
 coveragePasses dflags =
     ifa (breakpointsEnabled dflags)          Breakpoints $
     ifa (gopt Opt_Hpc dflags)                HpcTicks $
-    ifa (gopt Opt_SccProfilingOn dflags &&
+    ifa (sccProfilingEnabled dflags &&
          profAuto dflags /= NoProfAuto)      ProfNotes $
     ifa (debugLevel dflags > 0)              SourceNotes []
   where ifa f x xs | f         = x:xs


=====================================
compiler/GHC/HsToCore/Expr.hs
=====================================
@@ -813,7 +813,7 @@ dsExpr (HsRecFld      {})  = panic "dsExpr:HsRecFld"
 ds_prag_expr :: HsPragE GhcTc -> LHsExpr GhcTc -> DsM CoreExpr
 ds_prag_expr (HsPragSCC _ _ cc) expr = do
     dflags <- getDynFlags
-    if gopt Opt_SccProfilingOn dflags
+    if sccProfilingEnabled dflags
       then do
         mod_name <- getModule
         count <- goptM Opt_ProfCountEntries


=====================================
compiler/GHC/Iface/Recomp/Flags.hs
=====================================
@@ -55,7 +55,7 @@ fingerprintDynFlags dflags at DynFlags{..} this_mod nameio =
         paths = [ hcSuf ]
 
         -- -fprof-auto etc.
-        prof = if gopt Opt_SccProfilingOn dflags then fromEnum profAuto else 0
+        prof = if sccProfilingEnabled dflags then fromEnum profAuto else 0
 
         -- Ticky
         ticky =


=====================================
compiler/GHC/Runtime/Heap/Layout.hs
=====================================
@@ -282,8 +282,8 @@ fixedHdrSizeW dflags = sTD_HDR_SIZE dflags + profHdrSize dflags
 -- (StgProfHeader in includes\/rts\/storage\/Closures.h)
 profHdrSize  :: DynFlags -> WordOff
 profHdrSize dflags
- | gopt Opt_SccProfilingOn dflags = pROF_HDR_SIZE dflags
- | otherwise                      = 0
+ | sccProfilingEnabled dflags = pROF_HDR_SIZE dflags
+ | otherwise                  = 0
 
 -- | The garbage collector requires that every closure is at least as
 --   big as this.


=====================================
compiler/GHC/Stg/Syntax.hs
=====================================
@@ -805,7 +805,7 @@ pprStgRhs :: OutputablePass pass => GenStgRhs pass -> SDoc
 
 pprStgRhs (StgRhsClosure ext cc upd_flag args body)
   = sdocWithDynFlags $ \dflags ->
-    hang (hsep [if gopt Opt_SccProfilingOn dflags then ppr cc else empty,
+    hang (hsep [if sccProfilingEnabled dflags then ppr cc else empty,
                 ppUnlessOption sdocSuppressStgExts (ppr ext),
                 char '\\' <> ppr upd_flag, brackets (interppSP args)])
          4 (ppr body)


=====================================
compiler/GHC/StgToCmm/Bind.hs
=====================================
@@ -307,7 +307,7 @@ mkRhsClosure    dflags bndr _cc
   , all (isGcPtrRep . idPrimRep . fromNonVoid) fvs
   , isUpdatable upd_flag
   , n_fvs <= mAX_SPEC_AP_SIZE dflags
-  , not (gopt Opt_SccProfilingOn dflags)
+  , not (sccProfilingEnabled dflags)
                          -- not when profiling: we don't want to
                          -- lose information about this particular
                          -- thunk (e.g. its type) (#949)
@@ -626,7 +626,7 @@ emitBlackHoleCode node = do
   -- Note the eager-blackholing check is here rather than in blackHoleOnEntry,
   -- because emitBlackHoleCode is called from GHC.Cmm.Parser.
 
-  let  eager_blackholing =  not (gopt Opt_SccProfilingOn dflags)
+  let  eager_blackholing =  not (sccProfilingEnabled dflags)
                          && gopt Opt_EagerBlackHoling dflags
              -- Profiling needs slop filling (to support LDV
              -- profiling), so currently eager blackholing doesn't
@@ -655,7 +655,7 @@ setupUpdate closure_info node body
           dflags <- getDynFlags
           let
               bh = blackHoleOnEntry closure_info &&
-                   not (gopt Opt_SccProfilingOn dflags) &&
+                   not (sccProfilingEnabled dflags) &&
                    gopt Opt_EagerBlackHoling dflags
 
               lbl | bh        = mkBHUpdInfoLabel


=====================================
compiler/GHC/StgToCmm/Closure.hs
=====================================
@@ -381,7 +381,7 @@ nodeMustPointToIt dflags (LFThunk top no_fvs updatable NonStandardThunk _)
   =  not no_fvs            -- Self parameter
   || isNotTopLevel top     -- Note [GC recovery]
   || updatable             -- Need to push update frame
-  || gopt Opt_SccProfilingOn dflags
+  || sccProfilingEnabled dflags
           -- For the non-updatable (single-entry case):
           --
           -- True if has fvs (in which case we need access to them, and we
@@ -508,7 +508,7 @@ getCallMethod dflags _ id _ n_args v_args _cg_loc
 getCallMethod dflags name id (LFReEntrant _ arity _ _) n_args _v_args _cg_loc
               _self_loop_info
   | n_args == 0 -- No args at all
-  && not (gopt Opt_SccProfilingOn dflags)
+  && not (sccProfilingEnabled dflags)
      -- See Note [Evaluating functions with profiling] in rts/Apply.cmm
   = ASSERT( arity /= 0 ) ReturnIt
   | n_args < arity = SlowCall        -- Not enough args
@@ -859,7 +859,7 @@ enterIdLabel platform id c
 
 mkProfilingInfo :: DynFlags -> Id -> String -> ProfilingInfo
 mkProfilingInfo dflags id val_descr
-  | not (gopt Opt_SccProfilingOn dflags) = NoProfilingInfo
+  | not (sccProfilingEnabled dflags) = NoProfilingInfo
   | otherwise = ProfilingInfo ty_descr_w8 (BS8.pack val_descr)
   where
     ty_descr_w8  = BS8.pack (getTyDescription (idType id))
@@ -906,8 +906,8 @@ mkDataConInfoTable dflags data_con is_static ptr_wds nonptr_wds
                   -- We keep the *zero-indexed* tag in the srt_len field
                   -- of the info table of a data constructor.
 
-   prof | not (gopt Opt_SccProfilingOn dflags) = NoProfilingInfo
-        | otherwise                            = ProfilingInfo ty_descr val_descr
+   prof | not (sccProfilingEnabled dflags) = NoProfilingInfo
+        | otherwise                        = ProfilingInfo ty_descr val_descr
 
    ty_descr  = BS8.pack $ occNameString $ getOccName $ dataConTyCon data_con
    val_descr = BS8.pack $ occNameString $ getOccName data_con


=====================================
compiler/GHC/StgToCmm/Foreign.hs
=====================================
@@ -306,7 +306,7 @@ saveThreadState dflags = do
             spExpr,
     close_nursery,
     -- and save the current cost centre stack in the TSO when profiling:
-    if gopt Opt_SccProfilingOn dflags then
+    if sccProfilingEnabled dflags then
         mkStore (cmmOffset platform (CmmReg (CmmLocal tso)) (tso_CCCS dflags)) cccsExpr
       else mkNop
     ]
@@ -421,7 +421,7 @@ loadThreadState dflags = do
     mkAssign hpAllocReg (zeroExpr platform),
     open_nursery,
     -- and load the current cost centre stack from the TSO when profiling:
-    if gopt Opt_SccProfilingOn dflags
+    if sccProfilingEnabled dflags
        then storeCurCCS
               (CmmLoad (cmmOffset platform (CmmReg (CmmLocal tso))
                  (tso_CCCS dflags)) (ccsType platform))


=====================================
compiler/GHC/StgToCmm/Layout.hs
=====================================
@@ -367,7 +367,7 @@ just more arguments that we are passing on the stack (cml_args).
 slowArgs :: DynFlags -> [(ArgRep, Maybe CmmExpr)] -> [(ArgRep, Maybe CmmExpr)]
 slowArgs _ [] = []
 slowArgs dflags args -- careful: reps contains voids (V), but args does not
-  | gopt Opt_SccProfilingOn dflags
+  | sccProfilingEnabled dflags
               = save_cccs ++ this_pat ++ slowArgs dflags rest_args
   | otherwise =              this_pat ++ slowArgs dflags rest_args
   where


=====================================
compiler/GHC/StgToCmm/Prim.hs
=====================================
@@ -300,8 +300,8 @@ emitPrimOp dflags = \case
   GetCCSOfOp -> \[arg] -> opAllDone $ \[res] -> do
     let
       val
-       | gopt Opt_SccProfilingOn dflags = costCentreFrom dflags (cmmUntag dflags arg)
-       | otherwise                      = CmmLit (zeroCLit platform)
+       | sccProfilingEnabled dflags = costCentreFrom dflags (cmmUntag dflags arg)
+       | otherwise                  = CmmLit (zeroCLit platform)
     emitAssign (CmmLocal res) val
 
   GetCurrentCCSOp -> \[_] -> opAllDone $ \[res] -> do


=====================================
compiler/GHC/StgToCmm/Prof.hs
=====================================
@@ -76,15 +76,15 @@ costCentreFrom dflags cl = CmmLoad (cmmOffsetB platform cl (oFFSET_StgHeader_ccs
 -- | The profiling header words in a static closure
 staticProfHdr :: DynFlags -> CostCentreStack -> [CmmLit]
 staticProfHdr dflags ccs
-  | gopt Opt_SccProfilingOn dflags = [mkCCostCentreStack ccs, staticLdvInit platform]
-  | otherwise                      = []
+  | sccProfilingEnabled dflags = [mkCCostCentreStack ccs, staticLdvInit platform]
+  | otherwise                  = []
   where platform = targetPlatform dflags
 
 -- | Profiling header words in a dynamic closure
 dynProfHdr :: DynFlags -> CmmExpr -> [CmmExpr]
 dynProfHdr dflags ccs
-  | gopt Opt_SccProfilingOn dflags = [ccs, dynLdvInit dflags]
-  | otherwise                      = []
+  | sccProfilingEnabled dflags = [ccs, dynLdvInit dflags]
+  | otherwise                  = []
 
 -- | Initialise the profiling field of an update frame
 initUpdFrameProf :: CmmExpr -> FCode ()
@@ -130,7 +130,7 @@ saveCurrentCostCentre :: FCode (Maybe LocalReg)
 saveCurrentCostCentre
   = do dflags <- getDynFlags
        platform <- getPlatform
-       if not (gopt Opt_SccProfilingOn dflags)
+       if not (sccProfilingEnabled dflags)
            then return Nothing
            else do local_cc <- newTemp (ccType platform)
                    emitAssign (CmmLocal local_cc) cccsExpr
@@ -195,7 +195,7 @@ enterCostCentreFun ccs closure =
 ifProfiling :: FCode () -> FCode ()
 ifProfiling code
   = do dflags <- getDynFlags
-       if gopt Opt_SccProfilingOn dflags
+       if sccProfilingEnabled dflags
            then code
            else return ()
 
@@ -207,7 +207,7 @@ initCostCentres :: CollectedCCs -> FCode ()
 -- Emit the declarations
 initCostCentres (local_CCs, singleton_CCSs)
   = do dflags <- getDynFlags
-       when (gopt Opt_SccProfilingOn dflags) $
+       when (sccProfilingEnabled dflags) $
            do mapM_ emitCostCentreDecl local_CCs
               mapM_ emitCostCentreStackDecl singleton_CCSs
 
@@ -277,7 +277,7 @@ emitSetCCC :: CostCentre -> Bool -> Bool -> FCode ()
 emitSetCCC cc tick push
  = do dflags <- getDynFlags
       platform <- getPlatform
-      if not (gopt Opt_SccProfilingOn dflags)
+      if not (sccProfilingEnabled dflags)
           then return ()
           else do tmp <- newTemp (ccsType platform)
                   pushCostCentre tmp cccsExpr cc


=====================================
docs/users_guide/using-warnings.rst
=====================================
@@ -94,6 +94,11 @@ The following flags are simple ways to select standard "packages" of warnings:
         * :ghc-flag:`-Wpartial-fields`
         * :ghc-flag:`-Wmissed-specialisations`
         * :ghc-flag:`-Wall-missed-specialisations`
+        * :ghc-flag:`-Wcpp-undef`
+        * :ghc-flag:`-Wduplicate-constraints`
+        * :ghc-flag:`-Wmissing-deriving-strategies`
+        * :ghc-flag:`-Wunused-packages`
+        * :ghc-flag:`-Wunused-type-patterns`
 
 .. ghc-flag:: -Weverything
     :shortdesc: enable all warnings supported by GHC
@@ -119,7 +124,6 @@ The following flags are simple ways to select standard "packages" of warnings:
     .. hlist::
         :columns: 3
 
-        * :ghc-flag:`-Wmissing-monadfail-instances`
         * :ghc-flag:`-Wsemigroup`
         * :ghc-flag:`-Wnoncanonical-monoid-instances`
         * :ghc-flag:`-Wstar-is-type`


=====================================
rts/ProfHeap.c
=====================================
@@ -347,6 +347,16 @@ LDV_recordDead( const StgClosure *c, uint32_t size )
 STATIC_INLINE void
 initEra(Census *census)
 {
+    // N.B. When not LDV profiling we reinitialise the same Census over
+    // and over again. Consequently, we need to ensure that we free the
+    // resources from the previous census.
+    if (census->hash) {
+        freeHashTable(census->hash, NULL);
+    }
+    if (census->arena) {
+        arenaFree(census->arena);
+    }
+
     census->hash  = allocHashTable();
     census->ctrs  = NULL;
     census->arena = newArena();
@@ -498,18 +508,24 @@ initHeapProfiling(void)
 #if defined(PROFILING)
     if (doingLDVProfiling()) {
         era = 1;
+        n_censuses = 32;
     } else
 #endif
     {
         era = 0;
+        n_censuses = 1;
     }
 
     // max_era = 2^LDV_SHIFT
     max_era = 1 << LDV_SHIFT;
 
-    n_censuses = 32;
     censuses = stgMallocBytes(sizeof(Census) * n_censuses, "initHeapProfiling");
 
+    // Ensure that arena and hash are NULL since otherwise initEra will attempt to free them.
+    for (unsigned int i=0; i < n_censuses; i++) {
+        censuses[i].arena = NULL;
+        censuses[i].hash = NULL;
+    }
     initEra( &censuses[era] );
 
     /* initProfilingLogFile(); */



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ddfbf39253815245653d39c941792859c2948521...9e8fa44adaaad66eb95ffbb5aa74f0c768d7134b

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ddfbf39253815245653d39c941792859c2948521...9e8fa44adaaad66eb95ffbb5aa74f0c768d7134b
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200702/be9b5c3f/attachment-0001.html>


More information about the ghc-commits mailing list