From 02e278eb2ace60cf2acadd2f632b51b9017d5b56 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Wed, 20 May 2020 15:37:03 -0400 Subject: Coverage: Don't produce ModBreaks if not HscInterpreted emptyModBreaks contains a bottom and consequently it's important that we don't use it unless necessary. --- compiler/GHC/HsToCore/Coverage.hs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/compiler/GHC/HsToCore/Coverage.hs b/compiler/GHC/HsToCore/Coverage.hs index 7426aeaa96..c02bf8836a 100644 --- a/compiler/GHC/HsToCore/Coverage.hs +++ b/compiler/GHC/HsToCore/Coverage.hs @@ -117,7 +117,7 @@ addTicksToBinds hsc_env mod mod_loc exports tyCons binds dumpIfSet_dyn dflags Opt_D_dump_ticked "HPC" FormatHaskell (pprLHsBinds binds1) - return (binds1, HpcInfo tickCount hashNo, Just modBreaks) + return (binds1, HpcInfo tickCount hashNo, modBreaks) | otherwise = return (binds, emptyHpcInfo False, Nothing) @@ -134,23 +134,23 @@ guessSourceFile binds orig_file = _ -> orig_file -mkModBreaks :: HscEnv -> Module -> Int -> [MixEntry_] -> IO ModBreaks +mkModBreaks :: HscEnv -> Module -> Int -> [MixEntry_] -> IO (Maybe ModBreaks) mkModBreaks hsc_env mod count entries - | HscInterpreted <- hscTarget (hsc_dflags hsc_env) = do + | breakpointsEnabled (hsc_dflags hsc_env) = do breakArray <- GHCi.newBreakArray hsc_env (length entries) ccs <- mkCCSArray hsc_env mod count entries let locsTicks = listArray (0,count-1) [ span | (span,_,_,_) <- entries ] varsTicks = listArray (0,count-1) [ vars | (_,_,vars,_) <- entries ] declsTicks = listArray (0,count-1) [ decls | (_,decls,_,_) <- entries ] - return emptyModBreaks + return $ Just $ emptyModBreaks { modBreaks_flags = breakArray , modBreaks_locs = locsTicks , modBreaks_vars = varsTicks , modBreaks_decls = declsTicks , modBreaks_ccs = ccs } - | otherwise = return emptyModBreaks + | otherwise = return Nothing mkCCSArray :: HscEnv -> Module -> Int -> [MixEntry_] @@ -1027,7 +1027,7 @@ data TickishType = ProfNotes | HpcTicks | Breakpoints | SourceNotes coveragePasses :: DynFlags -> [TickishType] coveragePasses dflags = - ifa (hscTarget dflags == HscInterpreted) Breakpoints $ + ifa (breakpointsEnabled dflags) Breakpoints $ ifa (gopt Opt_Hpc dflags) HpcTicks $ ifa (gopt Opt_SccProfilingOn dflags && profAuto dflags /= NoProfAuto) ProfNotes $ @@ -1035,6 +1035,10 @@ coveragePasses dflags = where ifa f x xs | f = x:xs | otherwise = xs +-- | Should we produce 'Breakpoint' ticks? +breakpointsEnabled :: DynFlags -> Bool +breakpointsEnabled dflags = hscTarget dflags == HscInterpreted + -- | Tickishs that only make sense when their source code location -- refers to the current file. This might not always be true due to -- LINE pragmas in the code - which would confuse at least HPC. -- cgit v1.2.1