| ... |
... |
@@ -51,7 +51,6 @@ import GHC.Types.CostCentre.State |
|
51
|
51
|
import GHC.Types.Tickish
|
|
52
|
52
|
import GHC.Types.ProfAuto
|
|
53
|
53
|
import GHC.Tc.Types.ErrCtxt
|
|
54
|
|
-import GHC.Tc.Utils.TcType
|
|
55
|
54
|
|
|
56
|
55
|
import Control.Monad
|
|
57
|
56
|
import Data.List (isSuffixOf, intersperse)
|
| ... |
... |
@@ -313,7 +312,7 @@ addTickLHsBind (L pos (funBind@(FunBind { fun_id = L _ id, fun_matches = matches |
|
313
|
312
|
exported = idName id `elemNameSet` exported_names
|
|
314
|
313
|
|
|
315
|
314
|
-- See Note [Instance Method Coverage].
|
|
316
|
|
- let generatedInstMeth = density == TickForCoverage
|
|
|
315
|
+ let generatedInstMeth = tickishType env == HpcTicks
|
|
317
|
316
|
&& id `elemVarEnv` instMeths env
|
|
318
|
317
|
&& isGenerated (mg_origin (mg_ext matches))
|
|
319
|
318
|
|
| ... |
... |
@@ -1236,6 +1235,9 @@ getDensity = TM $ \env st -> (density env, noFVs, st) |
|
1236
|
1235
|
ifDensity :: TickDensity -> TM a -> TM a -> TM a
|
|
1237
|
1236
|
ifDensity d th el = do d0 <- getDensity; if d == d0 then th else el
|
|
1238
|
1237
|
|
|
|
1238
|
+ifTickish :: TickishType -> TM a -> TM a -> TM a
|
|
|
1239
|
+ifTickish want th el = tickishType <$> getEnv >>= \got -> if want == got then th else el
|
|
|
1240
|
+
|
|
1239
|
1241
|
getFreeVars :: TM a -> TM (FreeVars, a)
|
|
1240
|
1242
|
getFreeVars (TM m)
|
|
1241
|
1243
|
= TM $ \ env st -> case m env st of (a, fv, st') -> ((fv,a), fv, st')
|
| ... |
... |
@@ -1295,13 +1297,12 @@ isBlackListed UnhelpfulSpan{} = return False |
|
1295
|
1297
|
-- See Note [Instance Method Coverage].
|
|
1296
|
1298
|
allocInstTicks :: [ClsInst] -> TM (NameEnv CoreTickish)
|
|
1297
|
1299
|
allocInstTicks insts =
|
|
1298
|
|
- ifDensity TickForCoverage (mkNameEnv . catMaybes <$> mapM alloc insts) (pure emptyNameEnv)
|
|
|
1300
|
+ ifTickish HpcTicks (mkNameEnv . catMaybes <$> mapM alloc insts) (pure emptyNameEnv)
|
|
1299
|
1301
|
where
|
|
1300
|
1302
|
alloc ClsInst{ is_dfun, is_cls }
|
|
1301
|
1303
|
| null (classMethods is_cls) = pure Nothing
|
|
1302
|
|
- | otherwise = fmap (idName is_dfun,) <$> allocATickBox (TopLevelBox [s])
|
|
|
1304
|
+ | otherwise = fmap (idName is_dfun,) <$> allocATickBox (TopLevelBox [getOccString is_dfun])
|
|
1303
|
1305
|
False True (getSrcSpan is_dfun) noFVs
|
|
1304
|
|
- where s = showSDocOneLine defaultSDocContext (pprSigmaType (idType is_dfun))
|
|
1305
|
1306
|
|
|
1306
|
1307
|
-- See Note [Instance Method Coverage].
|
|
1307
|
1308
|
instMethTick :: Id -> TM (Maybe CoreTickish)
|
| ... |
... |
@@ -1325,7 +1326,7 @@ allocTickBox boxLabel countEntries topOnly pos m |
|
1325
|
1326
|
return (this_loc (XExpr $ HsTick tickish $ this_loc e))
|
|
1326
|
1327
|
|
|
1327
|
1328
|
recSelTick :: Id -> TM (Maybe [CoreTickish])
|
|
1328
|
|
-recSelTick id = ifDensity TickForCoverage maybe_tick (pure Nothing)
|
|
|
1329
|
+recSelTick id = ifTickish HpcTicks maybe_tick (pure Nothing)
|
|
1329
|
1330
|
where
|
|
1330
|
1331
|
maybe_tick = getEnv >>=
|
|
1331
|
1332
|
maybe (pure Nothing) tick_all . (`lookupVarEnv` id) . recSelBinds
|