summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-05-20 15:37:03 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-05-25 09:48:53 -0400
commit02e278eb2ace60cf2acadd2f632b51b9017d5b56 (patch)
tree85f231fa621d477ca6418d2ee1f26e2d2015023d
parentb28137505a2fc3a15f2c0ba31c39c1869ce65cdc (diff)
downloadhaskell-02e278eb2ace60cf2acadd2f632b51b9017d5b56.tar.gz
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.
-rw-r--r--compiler/GHC/HsToCore/Coverage.hs16
1 files 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.