summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Config/HsToCore/Ticks.hs
blob: 1f98a7e2eba344b0afe0e6dd211910636f845c81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module GHC.Driver.Config.HsToCore.Ticks
  ( initTicksConfig
  )
where

import GHC.Prelude

import Data.Maybe (catMaybes)

import GHC.Driver.Backend
import GHC.Driver.Session
import GHC.HsToCore.Ticks

initTicksConfig :: DynFlags -> TicksConfig
initTicksConfig dflags = TicksConfig
  { ticks_passes       = coveragePasses dflags
  , ticks_profAuto     = profAuto dflags
  , ticks_countEntries = gopt Opt_ProfCountEntries dflags
  }

coveragePasses :: DynFlags -> [TickishType]
coveragePasses dflags = catMaybes
  [ ifA Breakpoints $ backendWantsBreakpointTicks $ backend dflags
  , ifA HpcTicks $ gopt Opt_Hpc dflags
  , ifA ProfNotes $ sccProfilingEnabled dflags && profAuto dflags /= NoProfAuto
  , ifA SourceNotes $ needSourceNotes dflags
  ]
  where ifA x cond = if cond then Just x else Nothing