Skip to content

[question] Why do `-g` and `-fhpc` generate different `CoreTickish`es?

As far as I can tell, the TickDensity of both -g and -fhpc is TickForCoverage, so I'd expect both to generate the same CoreTickishes. However, it is not the case:

{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -fmax-simplifier-iterations=0 #-}
{-# OPTIONS_GHC -ddump-simpl #-}
{-# OPTIONS_GHC -O0 #-}

module A where

f = \(x :: Bool) (y :: Bool) -> x == y

From ghc -c -g A.hs:

f = \ (ds_dG9 :: Bool) (ds1_dGa :: Bool) ->
      src<A.hs:8:1-38>
      ==
        @Bool
        GHC.Classes.$fEqBool
        (src<A.hs:8:33> ds_dG9)
        (src<A.hs:8:38> ds1_dGa)

From ghc -c -fhpc A.hs:

f = hpc<A,4>
    hpc<A,3>
    \ (ds_dG9 :: Bool) (ds1_dGa :: Bool) ->
      hpc<A,2>
      == @Bool GHC.Classes.$fEqBool (hpc<A,0> ds_dG9) (hpc<A,1> ds1_dGa)

There are two differences:

  1. -g did not create Ticks on the Lambda.
  2. The source spans on == @Bool ... are different. -g gave 8:1-38, while -fhpc gave 8:33-38 (i.e., x == y).

Why the differences? The reason I'm asking is because the source spans I get from -fhpc are more useful to me, but -g is much more convenient.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information