summaryrefslogtreecommitdiff
path: root/compiler/codeGen
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2018-11-26 17:21:12 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-03-05 22:22:40 -0500
commit37f257afcd6a52cf4d76c60d766b1aeb520b9f05 (patch)
treeac800e46fbf94c16ce39170f4a720637b07dde06 /compiler/codeGen
parent646b6dfbe125aa756a935e840979ba11b4a882c0 (diff)
downloadhaskell-37f257afcd6a52cf4d76c60d766b1aeb520b9f05.tar.gz
Rip out object splitting
The splitter is an evil Perl script that processes assembler code. Its job can be done better by the linker's --gc-sections flag. GHC passes this flag to the linker whenever -split-sections is passed on the command line. This is based on @DemiMarie's D2768. Fixes Trac #11315 Fixes Trac #9832 Fixes Trac #8964 Fixes Trac #8685 Fixes Trac #8629
Diffstat (limited to 'compiler/codeGen')
-rw-r--r--compiler/codeGen/StgCmm.hs38
-rw-r--r--compiler/codeGen/StgCmmExpr.hs11
-rw-r--r--compiler/codeGen/StgCmmMonad.hs10
3 files changed, 8 insertions, 51 deletions
diff --git a/compiler/codeGen/StgCmm.hs b/compiler/codeGen/StgCmm.hs
index ff63b555ac..6cdb14880a 100644
--- a/compiler/codeGen/StgCmm.hs
+++ b/compiler/codeGen/StgCmm.hs
@@ -39,7 +39,6 @@ import Id
import IdInfo
import RepType
import DataCon
-import Name
import TyCon
import Module
import Outputable
@@ -120,17 +119,14 @@ variable. -}
cgTopBinding :: DynFlags -> CgStgTopBinding -> FCode ()
cgTopBinding dflags (StgTopLifted (StgNonRec id rhs))
- = do { id' <- maybeExternaliseId dflags id
- ; let (info, fcode) = cgTopRhs dflags NonRecursive id' rhs
+ = do { let (info, fcode) = cgTopRhs dflags NonRecursive id rhs
; fcode
- ; addBindC info -- Add the *un-externalised* Id to the envt,
- -- so we find it when we look up occurrences
+ ; addBindC info
}
cgTopBinding dflags (StgTopLifted (StgRec pairs))
= do { let (bndrs, rhss) = unzip pairs
- ; bndrs' <- Prelude.mapM (maybeExternaliseId dflags) bndrs
- ; let pairs' = zip bndrs' rhss
+ ; let pairs' = zip bndrs rhss
r = unzipWith (cgTopRhs dflags Recursive) pairs'
(infos, fcodes) = unzip r
; addBindsC infos
@@ -138,16 +134,14 @@ cgTopBinding dflags (StgTopLifted (StgRec pairs))
}
cgTopBinding dflags (StgTopStringLit id str)
- = do { id' <- maybeExternaliseId dflags id
- ; let label = mkBytesLabel (idName id')
+ = do { let label = mkBytesLabel (idName id)
; let (lit, decl) = mkByteStringCLit label str
; emitDecl decl
- ; addBindC (litIdInfo dflags id' mkLFStringLit lit)
+ ; addBindC (litIdInfo dflags id mkLFStringLit lit)
}
cgTopRhs :: DynFlags -> RecFlag -> Id -> CgStgRhs -> (CgIdInfo, FCode ())
-- The Id is passed along for setting up a binding...
- -- It's already been externalised if necessary
cgTopRhs dflags _rec bndr (StgRhsCon _cc con args)
= cgTopRhsCon dflags bndr con (assertNonVoidStgArgs args)
@@ -226,25 +220,3 @@ cgDataCon data_con
}
-- The case continuation code expects a tagged pointer
}
-
----------------------------------------------------------------
--- Stuff to support splitting
----------------------------------------------------------------
-
-maybeExternaliseId :: DynFlags -> Id -> FCode Id
-maybeExternaliseId dflags id
- | gopt Opt_SplitObjs dflags, -- See Note [Externalise when splitting]
- -- in StgCmmMonad
- isInternalName name = do { mod <- getModuleName
- ; return (setIdName id (externalise mod)) }
- | otherwise = return id
- where
- externalise mod = mkExternalName uniq mod new_occ loc
- name = idName id
- uniq = nameUnique name
- new_occ = mkLocalOcc uniq (nameOccName name)
- loc = nameSrcSpan name
- -- We want to conjure up a name that can't clash with any
- -- existing name. So we generate
- -- Mod_$L243foo
- -- where 243 is the unique.
diff --git a/compiler/codeGen/StgCmmExpr.hs b/compiler/codeGen/StgCmmExpr.hs
index 7a2340ed5f..5ad2e98abc 100644
--- a/compiler/codeGen/StgCmmExpr.hs
+++ b/compiler/codeGen/StgCmmExpr.hs
@@ -758,19 +758,14 @@ cgIdApp fun_id args = do
dflags <- getDynFlags
fun_info <- getCgIdInfo fun_id
self_loop_info <- getSelfLoop
- let cg_fun_id = cg_id fun_info
- -- NB: use (cg_id fun_info) instead of fun_id, because
- -- the former may be externalised for -split-objs.
- -- See Note [Externalise when splitting] in StgCmmMonad
-
- fun_arg = StgVarArg cg_fun_id
- fun_name = idName cg_fun_id
+ let fun_arg = StgVarArg fun_id
+ fun_name = idName fun_id
fun = idInfoToAmode fun_info
lf_info = cg_lf fun_info
n_args = length args
v_args = length $ filter (isVoidTy . stgArgType) args
node_points dflags = nodeMustPointToIt dflags lf_info
- case getCallMethod dflags fun_name cg_fun_id lf_info n_args v_args (cg_loc fun_info) self_loop_info of
+ case getCallMethod dflags fun_name fun_id lf_info n_args v_args (cg_loc fun_info) self_loop_info of
-- A value in WHNF, so we can just return it.
ReturnIt
| isVoidTy (idType fun_id) -> emitReturn []
diff --git a/compiler/codeGen/StgCmmMonad.hs b/compiler/codeGen/StgCmmMonad.hs
index 9ddd8a3985..b93e0ab6eb 100644
--- a/compiler/codeGen/StgCmmMonad.hs
+++ b/compiler/codeGen/StgCmmMonad.hs
@@ -174,20 +174,10 @@ type CgBindings = IdEnv CgIdInfo
data CgIdInfo
= CgIdInfo
{ cg_id :: Id -- Id that this is the info for
- -- Can differ from the Id at occurrence sites by
- -- virtue of being externalised, for splittable C
- -- See Note [Externalise when splitting]
, cg_lf :: LambdaFormInfo
, cg_loc :: CgLoc -- CmmExpr for the *tagged* value
}
--- Note [Externalise when splitting]
--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- If we're splitting the object with -fsplit-objs, we need to
--- externalise *all* the top-level names, and then make sure we only
--- use the externalised one in any C label we use which refers to this
--- name.
-
instance Outputable CgIdInfo where
ppr (CgIdInfo { cg_id = id, cg_loc = loc })
= ppr id <+> text "-->" <+> ppr loc