Skip to content

Specialiser doesn't see through source location annotations

Unfortunately, this is a similar situation to #21489 (closed) in that I haven't found a way to trigger this problem with vanilla GHC, but it does occur on the fork I've been working on.

It seems that when the specialiser is collecting usage details and encounters an application, if the application head is a Var wrapped in Ticks or Casts, then this occurrence is not recorded:

specExpr env expr@(App {})
  = go expr []
  where
    go (App fun arg) args = do (arg', uds_arg) <- specExpr env arg
                               (fun', uds_app) <- go fun (arg':args)
                               return (App fun' arg', uds_arg `plusUDs` uds_app)

    go (Var f)       args = case specVar env f of
                                Var f' -> return (Var f', mkCallUDs env f' args)
                                e'     -> return (e', emptyUDs) -- I don't expect this!
    go other         _    = specExpr env other

This is a problem if e.g. -finfo-table-map is turned on, since the Tick containing the source location can now inhibit a specialisation that would otherwise happen without the source locations.

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