Commit 386c2d7f authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot

Use UnitId in the backend instead of Unit

In Cmm we can only have real units identified with an UnitId.  Other
units (on-the-fly instantiated units and holes) are only used in
type-checking backpack sessions that don't produce Cmm.
parent e91ddddd
......@@ -387,7 +387,7 @@ instance Ord CLabel where
data ForeignLabelSource
-- | Label is in a named package
= ForeignLabelInPackage Unit
= ForeignLabelInPackage UnitId
-- | Label is in some external, system package that doesn't also
-- contain compiled Haskell code, and is not associated with any .hi files.
......@@ -1087,15 +1087,15 @@ labelDynamic config this_mod lbl =
case lbl of
-- is the RTS in a DLL or not?
RtsLabel _ ->
externalDynamicRefs && (this_pkg /= rtsUnit)
externalDynamicRefs && (this_unit /= rtsUnitId)
IdLabel n _ _ ->
externalDynamicRefs && isDynLinkName platform this_mod n
-- When compiling in the "dyn" way, each package is to be linked into
-- its own shared library.
CmmLabel pkg _ _ _
| os == OSMinGW32 -> externalDynamicRefs && (toUnitId this_pkg /= pkg)
CmmLabel lbl_unit _ _ _
| os == OSMinGW32 -> externalDynamicRefs && (this_unit /= lbl_unit)
| otherwise -> externalDynamicRefs
LocalBlockLabel _ -> False
......@@ -1114,7 +1114,7 @@ labelDynamic config this_mod lbl =
-- When compiling in the "dyn" way, each package is to be
-- linked into its own DLL.
ForeignLabelInPackage pkgId ->
externalDynamicRefs && (this_pkg /= pkgId)
externalDynamicRefs && (this_unit /= pkgId)
else -- On Mac OS X and on ELF platforms, false positives are OK,
-- so we claim that all foreign imports come from dynamic
......@@ -1136,7 +1136,7 @@ labelDynamic config this_mod lbl =
externalDynamicRefs = ncgExternalDynamicRefs config
platform = ncgPlatform config
os = platformOS platform
this_pkg = moduleUnit this_mod
this_unit = toUnitId (moduleUnit this_mod)
-----------------------------------------------------------------------------
......
......@@ -47,6 +47,7 @@ import GHC.Data.Maybe
import GHC.Utils.Panic
import GHC.Types.Unique.Supply
import GHC.Types.Basic
import GHC.Unit.Types
import GHC.Core.TyCo.Rep
import GHC.Builtin.Types.Prim
......@@ -91,7 +92,7 @@ cgForeignCall (CCall (CCallSpec target cconv safety)) typ stg_args res_ty
-> let labelSource
= case mPkgId of
Nothing -> ForeignLabelInThisPackage
Just pkgId -> ForeignLabelInPackage pkgId
Just pkgId -> ForeignLabelInPackage (toUnitId pkgId)
size = call_size cmm_args
in ( unzip cmm_args
, CmmLit (CmmLabel
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment