never executed always true always false
1 -----------------------------------------------------------------------------
2 --
3 -- Code generation for coverage
4 --
5 -- (c) Galois Connections, Inc. 2006
6 --
7 -----------------------------------------------------------------------------
8
9 module GHC.StgToCmm.Hpc ( initHpc, mkTickBox ) where
10
11 import GHC.Prelude
12 import GHC.Platform
13
14 import GHC.Driver.Session
15
16 import GHC.StgToCmm.Monad
17 import GHC.StgToCmm.Utils
18
19 import GHC.Cmm.Graph
20 import GHC.Cmm.Expr
21 import GHC.Cmm.CLabel
22 import GHC.Cmm.Utils
23
24 import GHC.Unit.Module
25 import GHC.Types.HpcInfo
26
27 import Control.Monad
28
29 mkTickBox :: Platform -> Module -> Int -> CmmAGraph
30 mkTickBox platform mod n
31 = mkStore tick_box (CmmMachOp (MO_Add W64)
32 [ CmmLoad tick_box b64
33 , CmmLit (CmmInt 1 W64)
34 ])
35 where
36 tick_box = cmmIndex platform W64
37 (CmmLit $ CmmLabel $ mkHpcTicksLabel $ mod)
38 n
39
40 -- | Emit top-level tables for HPC and return code to initialise
41 initHpc :: Module -> HpcInfo -> FCode ()
42 initHpc _ (NoHpcInfo {})
43 = return ()
44 initHpc this_mod (HpcInfo tickCount _hashNo)
45 = do dflags <- getDynFlags
46 when (gopt Opt_Hpc dflags) $
47 emitDataLits (mkHpcTicksLabel this_mod)
48 [ (CmmInt 0 W64)
49 | _ <- take tickCount [0 :: Int ..]
50 ]
51