summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-02-09 13:41:41 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-02-23 08:16:43 -0500
commit2ed22ba19e6324fda81a7d638f6f3b58254f915f (patch)
treecd65549948db3d55ff531cd39eb4120ed4bae098
parenta599abbad939820c666ced00ae9eb33706a4f360 (diff)
downloadhaskell-2ed22ba19e6324fda81a7d638f6f3b58254f915f.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.hs2
-rw-r--r--compiler/GHC/Driver/Session.hs6
-rw-r--r--compiler/GHC/HsToCore/Coverage.hs6
-rw-r--r--compiler/GHC/IfaceToCore.hs4
4 files changed, 10 insertions, 8 deletions
diff --git a/compiler/GHC/CoreToStg/Prep.hs b/compiler/GHC/CoreToStg/Prep.hs
index ac626931cd..8a6354147c 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 34d34815ce..f7d05d063d 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(..),
@@ -4841,6 +4842,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 1c6ef3eafa..c59beb402c 100644
--- a/compiler/GHC/HsToCore/Coverage.hs
+++ b/compiler/GHC/HsToCore/Coverage.hs
@@ -1066,17 +1066,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 2982df668d..2e98f45745 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