summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-02-09 13:41:41 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2022-02-11 10:12:12 +0000
commit6c8d5511854aed4ee9c23972fa00f79dacf0b0b0 (patch)
tree2ecd552920c0a3e1d4c30523c524f0c0c75c50fd
parentdd4f50d8f7c610660a136fca33ed1599aa632470 (diff)
downloadhaskell-6c8d5511854aed4ee9c23972fa00f79dacf0b0b0.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 (cherry picked from commit 1316f7dadf0f538f09f8b97629c7e5f6f868266d)
-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 b5dd0d7b2a..bd99bf976d 100644
--- a/compiler/GHC/CoreToStg/Prep.hs
+++ b/compiler/GHC/CoreToStg/Prep.hs
@@ -310,7 +310,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 aa951a13bd..50d393019c 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -42,6 +42,7 @@ module GHC.Driver.Session (
DynamicTooState(..), dynamicTooState, setDynamicNow, setDynamicTooFailed,
dynamicOutputFile, dynamicOutputHi,
sccProfilingEnabled,
+ needSourceNotes,
DynFlags(..),
outputFile, hiSuf, objectSuf, ways,
FlagSpec(..),
@@ -4910,6 +4911,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 8a6bb4e160..2ba6dd3ae6 100644
--- a/compiler/GHC/HsToCore/Coverage.hs
+++ b/compiler/GHC/HsToCore/Coverage.hs
@@ -1047,17 +1047,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 6425ebfc7f..f9e6fe7eb2 100644
--- a/compiler/GHC/IfaceToCore.hs
+++ b/compiler/GHC/IfaceToCore.hs
@@ -1537,9 +1537,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