summaryrefslogtreecommitdiff
path: root/compiler/cmm/CLabel.hs
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2018-05-22 09:36:35 -0400
committerBen Gamari <ben@smart-cactus.org>2018-05-23 16:49:51 -0400
commitbf10456edaa03dc010821cd4c3d9f49cb11d89da (patch)
tree38c508cad2bd3690fafd6f3d96d3dc1b029ed45a /compiler/cmm/CLabel.hs
parentd424d4a46a729f8530e9273282d22b6b8f34daaa (diff)
downloadhaskell-bf10456edaa03dc010821cd4c3d9f49cb11d89da.tar.gz
Disable the SRT offset optimisation on MachO platforms
Unfortunately, this optimisation is infeasible on MachO platforms (e.g. Darwin) due to an object format limitation. Specifically, linking fails with errors of the form: error: unsupported relocation with subtraction expression, symbol '_integerzmgmp_GHCziIntegerziType_quotInteger_closure' can not be undefined in a subtraction expression Apparently MachO does not permit relocations' subtraction expressions to refer to undefined symbols. As far as I can tell this means that it is essentially impossible to express an offset between symbols living in different compilation units. This means that we lively can't use this optimisation on MachO platforms. Test Plan: Validate on Darwin Reviewers: simonmar, erikd Subscribers: rwbarton, thomie, carter, angerman GHC Trac Issues: #15169 Differential Revision: https://phabricator.haskell.org/D4715
Diffstat (limited to 'compiler/cmm/CLabel.hs')
-rw-r--r--compiler/cmm/CLabel.hs22
1 files changed, 20 insertions, 2 deletions
diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs
index 3dfd7a7d1d..8f614ab34f 100644
--- a/compiler/cmm/CLabel.hs
+++ b/compiler/cmm/CLabel.hs
@@ -94,10 +94,12 @@ module CLabel (
mkHpcTicksLabel,
+ -- * Predicates
hasCAF,
needsCDecl, maybeLocalBlockLabel, externallyVisibleCLabel,
isMathFun,
isCFunctionLabel, isGcPtrLabel, labelDynamic,
+ isLocalCLabel,
-- * Conversions
toClosureLbl, toSlowEntryLbl, toEntryLbl, toInfoLbl, hasHaskellName,
@@ -975,13 +977,29 @@ idInfoLabelType info =
-- -----------------------------------------------------------------------------
--- Does a CLabel need dynamic linkage?
+-- | Is a 'CLabel' defined in the current module being compiled?
+--
+-- Sometimes we can optimise references within a compilation unit in ways that
+-- we couldn't for inter-module references. This provides a conservative
+-- estimate of whether a 'CLabel' lives in the current module.
+isLocalCLabel :: Module -> CLabel -> Bool
+isLocalCLabel this_mod lbl =
+ case lbl of
+ IdLabel name _ _
+ | isInternalName name -> True
+ | otherwise -> nameModule name == this_mod
+ LocalBlockLabel _ -> True
+ _ -> False
+
+-- -----------------------------------------------------------------------------
+
+-- | Does a 'CLabel' need dynamic linkage?
+--
-- When referring to data in code, we need to know whether
-- that data resides in a DLL or not. [Win32 only.]
-- @labelDynamic@ returns @True@ if the label is located
-- in a DLL, be it a data reference or not.
-
labelDynamic :: DynFlags -> Module -> CLabel -> Bool
labelDynamic dflags this_mod lbl =
case lbl of