diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2022-02-09 13:41:41 +0000 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2022-02-09 13:53:22 +0000 |
commit | 1316f7dadf0f538f09f8b97629c7e5f6f868266d (patch) | |
tree | 085531aa652cdf730ba505fc6a462b59eacc58fd | |
parent | 1dbe5b2a97c41b3f24a48372ba25faeae08e8cd6 (diff) | |
download | haskell-1316f7dadf0f538f09f8b97629c7e5f6f868266d.tar.gz |
Introduce predicate for when to enable source notes (needSourceNotes)
There were situations where we were using debugLevel == 0 as a proxy for
whether to retain source notes but -finfo-table-map also enables and
needs source notes so we should act consistently in both cases.
Ticket #20847
-rw-r--r-- | compiler/GHC/CoreToStg/Prep.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Driver/Session.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/HsToCore/Coverage.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/IfaceToCore.hs | 4 |
4 files changed, 10 insertions, 8 deletions
diff --git a/compiler/GHC/CoreToStg/Prep.hs b/compiler/GHC/CoreToStg/Prep.hs index 99c4cd4e8c..0ac4ed24a1 100644 --- a/compiler/GHC/CoreToStg/Prep.hs +++ b/compiler/GHC/CoreToStg/Prep.hs @@ -299,7 +299,7 @@ mkDataConWorkers dflags mod_loc data_tycons -- If we want to generate debug info, we put a source note on the -- worker. This is useful, especially for heap profiling. tick_it name - | debugLevel dflags == 0 = id + | not (needSourceNotes dflags) = id | RealSrcSpan span _ <- nameSrcSpan name = tick span | Just file <- ml_hs_file mod_loc = tick (span1 file) | otherwise = tick (span1 "???") diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs index 9640c13a66..dd5aeb8b7e 100644 --- a/compiler/GHC/Driver/Session.hs +++ b/compiler/GHC/Driver/Session.hs @@ -40,6 +40,7 @@ module GHC.Driver.Session ( lang_set, DynamicTooState(..), dynamicTooState, setDynamicNow, sccProfilingEnabled, + needSourceNotes, DynFlags(..), outputFile, objectSuf, ways, FlagSpec(..), @@ -4828,6 +4829,11 @@ isBmi2Enabled dflags = case platformArch (targetPlatform dflags) of sccProfilingEnabled :: DynFlags -> Bool sccProfilingEnabled dflags = profileIsProfiling (targetProfile dflags) +-- | Indicate whether we need to generate source notes +needSourceNotes :: DynFlags -> Bool +needSourceNotes dflags = debugLevel dflags > 0 + || gopt Opt_InfoTableMap dflags + -- ----------------------------------------------------------------------------- -- Linker/compiler information diff --git a/compiler/GHC/HsToCore/Coverage.hs b/compiler/GHC/HsToCore/Coverage.hs index 77c6ba651c..8050332a0f 100644 --- a/compiler/GHC/HsToCore/Coverage.hs +++ b/compiler/GHC/HsToCore/Coverage.hs @@ -1067,17 +1067,13 @@ data TickTransEnv = TTE { fileName :: FastString data TickishType = ProfNotes | HpcTicks | Breakpoints | SourceNotes deriving (Eq) -sourceNotesEnabled :: DynFlags -> Bool -sourceNotesEnabled dflags = - (debugLevel dflags > 0) || (gopt Opt_InfoTableMap dflags) - coveragePasses :: DynFlags -> [TickishType] coveragePasses dflags = ifa (breakpointsEnabled dflags) Breakpoints $ ifa (gopt Opt_Hpc dflags) HpcTicks $ ifa (sccProfilingEnabled dflags && profAuto dflags /= NoProfAuto) ProfNotes $ - ifa (sourceNotesEnabled dflags) SourceNotes [] + ifa (needSourceNotes dflags) SourceNotes [] where ifa f x xs | f = x:xs | otherwise = xs diff --git a/compiler/GHC/IfaceToCore.hs b/compiler/GHC/IfaceToCore.hs index 3a11c30e79..e993f0487b 100644 --- a/compiler/GHC/IfaceToCore.hs +++ b/compiler/GHC/IfaceToCore.hs @@ -1553,9 +1553,9 @@ tcIfaceExpr (IfaceLet (IfaceRec pairs) body) tcIfaceExpr (IfaceTick tickish expr) = do expr' <- tcIfaceExpr expr -- If debug flag is not set: Ignore source notes - dbgLvl <- fmap debugLevel getDynFlags + need_notes <- needSourceNotes <$> getDynFlags case tickish of - IfaceSource{} | dbgLvl == 0 + IfaceSource{} | not (need_notes) -> return expr' _otherwise -> do tickish' <- tcIfaceTickish tickish |