[Git][ghc/ghc][wip/osa1/lfinfo] Revert some of the changes

Ömer Sinan Ağacan gitlab at gitlab.haskell.org
Wed Mar 25 07:10:20 UTC 2020



Ömer Sinan Ağacan pushed to branch wip/osa1/lfinfo at Glasgow Haskell Compiler / GHC


Commits:
da40331b by Ömer Sinan Ağacan at 2020-03-25T10:09:57+03:00
Revert some of the changes

- - - - -


3 changed files:

- compiler/GHC/IfaceToCore.hs
- compiler/GHC/StgToCmm/Closure.hs
- compiler/GHC/StgToCmm/Env.hs


Changes:

=====================================
compiler/GHC/IfaceToCore.hs
=====================================
@@ -32,8 +32,6 @@ import GHC.Iface.Syntax
 import GHC.Iface.Load
 import GHC.Iface.Env
 import GHC.StgToCmm.Types
-import GHC.StgToCmm.Closure
-import GHC.Types.RepType
 import BuildTyCl
 import TcRnMonad
 import TcType
@@ -645,7 +643,7 @@ tc_iface_decl _ ignore_prags (IfaceId {ifName = name, ifType = iface_type,
   = do  { ty <- tcIfaceType iface_type
         ; details <- tcIdDetails ty details
         ; info <- tcIdInfo ignore_prags TopLevel name ty info
-        ; return (AnId (addIdLFInfo (mkGlobalId details name ty info))) }
+        ; return (AnId (mkGlobalId details name ty info)) }
 
 tc_iface_decl _ _ (IfaceData {ifName = tc_name,
                           ifCType = cType,
@@ -1344,8 +1342,7 @@ tcIfaceExpr (IfaceLet (IfaceNonRec (IfLetBndr fs ty info ji) rhs) body)
         ; ty'     <- tcIfaceType ty
         ; id_info <- tcIdInfo False {- Don't ignore prags; we are inside one! -}
                               NotTopLevel name ty' info
-        ; let id = addIdLFInfo $
-                   mkLocalIdWithInfo name ty' id_info
+        ; let id = mkLocalIdWithInfo name ty' id_info
                      `asJoinId_maybe` tcJoinInfo ji
         ; rhs' <- tcIfaceExpr rhs
         ; body' <- extendIfaceIdEnv [id] (tcIfaceExpr body)
@@ -1366,7 +1363,7 @@ tcIfaceExpr (IfaceLet (IfaceRec pairs) body)
      = do { rhs' <- tcIfaceExpr rhs
           ; id_info <- tcIdInfo False {- Don't ignore prags; we are inside one! -}
                                 NotTopLevel (idName id) (idType id) info
-          ; return (addIdLFInfo (setIdInfo id id_info), rhs') }
+          ; return (setIdInfo id id_info, rhs') }
 
 tcIfaceExpr (IfaceTick tickish expr) = do
     expr' <- tcIfaceExpr expr
@@ -1501,34 +1498,6 @@ tcIdInfo ignore_prags toplvl name ty info = do
                        | otherwise = info
            ; return (info1 `setUnfoldingInfo` unf) }
 
-addIdLFInfo :: Id -> Id
-addIdLFInfo id = case idLFInfo_maybe id of
-                   Nothing -> setIdLFInfo id (mkLFImported (idDetails id) (idInfo id) (idType id))
-                   Just _  -> id
-
--- Make a LambdaFormInfo for the Ids without a LFInfo in the iface file
-mkLFImported :: IdDetails -> IdInfo -> Type -> LambdaFormInfo
-mkLFImported details info ty
-  | DataConWorkId con <- details
-  , isNullaryRepDataCon con
-  = LFCon con   -- An imported nullary constructor
-                -- We assume that the constructor is evaluated so that
-                -- the id really does point directly to the constructor
-
-  | arity > 0
-  = LFReEntrant TopLevel noOneShotInfo arity True ArgUnknown
-
-  | isUnliftedType ty
-  = LFUnlifted
-
-  | mightBeAFunction ty
-  = LFUnknown True
-
-  | otherwise
-  = LFUnknown False
-  where
-    arity = countFunRepArgs (arityInfo info) ty
-
 tcJoinInfo :: IfaceJoinInfo -> Maybe JoinArity
 tcJoinInfo (IfaceJoinPoint ar) = Just ar
 tcJoinInfo IfaceNotJoinPoint   = Nothing


=====================================
compiler/GHC/StgToCmm/Closure.hs
=====================================
@@ -24,7 +24,7 @@ module GHC.StgToCmm.Closure (
         LambdaFormInfo,         -- Abstract
         StandardFormInfo,        -- ...ditto...
         mkLFThunk, mkLFReEntrant, mkConLFInfo, mkSelectorLFInfo,
-        mkApLFInfo, mkLFArgument, mkLFLetNoEscape,
+        mkApLFInfo, mkLFImported, mkLFArgument, mkLFLetNoEscape,
         mkLFStringLit,
         lfDynTag,
         isLFThunk, isLFReEntrant, lfUpdatable,
@@ -51,7 +51,6 @@ module GHC.StgToCmm.Closure (
         closureUpdReqd, closureSingleEntry,
         closureReEntrant, closureFunInfo,
         isToplevClosure,
-        mightBeAFunction,
 
         blackHoleOnEntry,  -- Needs LambdaFormInfo and SMRep
         isStaticClosure,   -- Needs SMPre
@@ -196,9 +195,9 @@ argPrimRep arg = typePrimRep1 (stgArgType arg)
 
 mkLFArgument :: Id -> LambdaFormInfo
 mkLFArgument id
-  | isUnliftedType ty   = LFUnlifted
-  | mightBeAFunction ty = LFUnknown True
-  | otherwise           = LFUnknown False
+  | isUnliftedType ty      = LFUnlifted
+  | might_be_a_function ty = LFUnknown True
+  | otherwise              = LFUnknown False
   where
     ty = idType id
 
@@ -226,13 +225,13 @@ mkLFThunk thunk_ty top fvs upd_flag
     LFThunk top (null fvs)
             (isUpdatable upd_flag)
             NonStandardThunk
-            (mightBeAFunction thunk_ty)
+            (might_be_a_function thunk_ty)
 
 --------------
-mightBeAFunction :: Type -> Bool
+might_be_a_function :: Type -> Bool
 -- Return False only if we are *sure* it's a data type
 -- Look through newtypes etc as much as poss
-mightBeAFunction ty
+might_be_a_function ty
   | [LiftedRep] <- typePrimRep ty
   , Just tc <- tyConAppTyCon_maybe (unwrapType ty)
   , isDataTyCon tc
@@ -248,13 +247,34 @@ mkConLFInfo con = LFCon con
 mkSelectorLFInfo :: Id -> Int -> Bool -> LambdaFormInfo
 mkSelectorLFInfo id offset updatable
   = LFThunk NotTopLevel False updatable (SelectorThunk offset)
-        (mightBeAFunction (idType id))
+        (might_be_a_function (idType id))
 
 -------------
 mkApLFInfo :: Id -> UpdateFlag -> Arity -> LambdaFormInfo
 mkApLFInfo id upd_flag arity
   = LFThunk NotTopLevel (arity == 0) (isUpdatable upd_flag) (ApThunk arity)
-        (mightBeAFunction (idType id))
+        (might_be_a_function (idType id))
+
+-------------
+mkLFImported :: Id -> LambdaFormInfo
+mkLFImported id =
+    case idLFInfo_maybe id of
+      Just lf_info ->
+        lf_info
+      Nothing
+        | Just con <- isDataConWorkId_maybe id
+        , isNullaryRepDataCon con
+        -> LFCon con   -- An imported nullary constructor
+                       -- We assume that the constructor is evaluated so that
+                       -- the id really does point directly to the constructor
+
+        | arity > 0
+        -> LFReEntrant TopLevel noOneShotInfo arity True ArgUnknown
+
+        | otherwise
+        -> mkLFArgument id -- Not sure of exact arity
+  where
+    arity = idFunRepArity id
 
 -------------
 mkLFStringLit :: LambdaFormInfo


=====================================
compiler/GHC/StgToCmm/Env.hs
=====================================
@@ -31,7 +31,6 @@ import GHC.Platform
 import GHC.StgToCmm.Monad
 import GHC.StgToCmm.Utils
 import GHC.StgToCmm.Closure
-import GHC.StgToCmm.Types
 
 import GHC.Cmm.CLabel
 
@@ -49,8 +48,6 @@ import TysPrim
 import UniqFM
 import Util
 import VarEnv
-import GHC.Core.DataCon
-import BasicTypes
 
 -------------------------------------
 --        Manipulating CgIdInfo
@@ -149,26 +146,6 @@ getCgIdInfo id
               cgLookupPanic id -- Bug
         }}}
 
-mkLFImported :: Id -> LambdaFormInfo
-mkLFImported id =
-    case idLFInfo_maybe id of
-      Just lf_info ->
-        lf_info
-      Nothing
-        | Just con <- isDataConWorkId_maybe id
-        , isNullaryRepDataCon con
-        -> LFCon con   -- An imported nullary constructor
-                       -- We assume that the constructor is evaluated so that
-                       -- the id really does point directly to the constructor
-
-        | arity > 0
-        -> LFReEntrant TopLevel noOneShotInfo arity True ArgUnknown
-
-        | otherwise
-        -> mkLFArgument id -- Not sure of exact arity
-  where
-    arity = idFunRepArity id
-
 cgLookupPanic :: Id -> FCode a
 cgLookupPanic id
   = do  local_binds <- getBinds



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da40331b7c57e6b3a87da389a884ae6dd2cacf36

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/da40331b7c57e6b3a87da389a884ae6dd2cacf36
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200325/034abbe3/attachment-0001.html>


More information about the ghc-commits mailing list