[project @ 1996-06-26 10:26:00 by partain]
[ghc-hetmet.git] / ghc / compiler / simplCore / OccurAnal.lhs
index cc7d4fb..8a91871 100644 (file)
@@ -17,23 +17,24 @@ module OccurAnal (
        occurAnalyseBinds, occurAnalyseExpr, occurAnalyseGlobalExpr
     ) where
 
-import Ubiq{-uitous-}
+IMP_Ubiq(){-uitous-}
+IMPORT_DELOOPER(IdLoop)        -- paranoia
 
 import BinderInfo
 import CmdLineOpts     ( opt_D_dump_occur_anal, SimplifierSwitch(..) )
 import CoreSyn
 import Digraph         ( stronglyConnComp )
 import Id              ( idWantsToBeINLINEd, isConstMethodId,
+                         externallyVisibleId,
                          emptyIdSet, unionIdSets, mkIdSet,
                          unitIdSet, elementOfIdSet,
-                         addOneToIdSet, IdSet(..),
+                         addOneToIdSet, SYN_IE(IdSet),
                          nullIdEnv, unitIdEnv, combineIdEnvs,
                          delOneFromIdEnv, delManyFromIdEnv,
-                         mapIdEnv, lookupIdEnv, IdEnv(..),
+                         mapIdEnv, lookupIdEnv, SYN_IE(IdEnv),
                          GenId{-instance Eq-}
                        )
 import Maybes          ( maybeToBool )
-import Name            ( isExported )
 import Outputable      ( Outputable(..){-instance * (,) -} )
 import PprCore
 import PprStyle                ( PprStyle(..) )
@@ -102,14 +103,14 @@ combineUsageDetails, combineAltsUsageDetails
        :: UsageDetails -> UsageDetails -> UsageDetails
 
 combineUsageDetails usage1 usage2
-  = combineIdEnvs combineBinderInfo usage1 usage2
+  = combineIdEnvs addBinderInfo usage1 usage2
 
 combineAltsUsageDetails usage1 usage2
-  = combineIdEnvs combineAltsBinderInfo usage1 usage2
+  = combineIdEnvs orBinderInfo usage1 usage2
 
 addOneOcc :: UsageDetails -> Id -> BinderInfo -> UsageDetails
 addOneOcc usage id info
-  = combineIdEnvs combineBinderInfo usage (unitIdEnv id info)
+  = combineIdEnvs addBinderInfo usage (unitIdEnv id info)
        -- ToDo: make this more efficient
 
 emptyDetails = (nullIdEnv :: UsageDetails)
@@ -137,7 +138,7 @@ tagBinder usage binder
     )
 
 usage_of usage binder
-  | isExported binder = ManyOcc        0 -- Exported things count as many
+  | externallyVisibleId binder = ManyOcc 0 -- Visible-elsewhere things count as many
   | otherwise
   = case (lookupIdEnv usage binder) of
       Nothing   -> DeadCode
@@ -170,7 +171,7 @@ occurAnalyseBinds binds simplifier_sw_chkr
                                     binds'
   | otherwise            = binds'
   where
-    (_, binds') = do initial_env binds
+    (_, binds') = doo initial_env binds
 
     initial_env = OccEnv (simplifier_sw_chkr KeepUnusedBindings)
                         (simplifier_sw_chkr KeepSpecPragmaIds)
@@ -178,12 +179,12 @@ occurAnalyseBinds binds simplifier_sw_chkr
                         (simplifier_sw_chkr IgnoreINLINEPragma)
                         emptyIdSet
 
-    do env [] = (emptyDetails, [])
-    do env (bind:binds)
+    doo env [] = (emptyDetails, [])
+    doo env (bind:binds)
       = (final_usage, new_binds ++ the_rest)
       where
        new_env                  = env `addNewCands` (bindersOf bind)
-       (binds_usage, the_rest)  = do new_env binds
+       (binds_usage, the_rest)  = doo new_env binds
        (final_usage, new_binds) = occAnalBind env bind binds_usage
 \end{code}
 
@@ -206,7 +207,7 @@ occurAnalyseGlobalExpr :: CoreExpr -> SimplifiableCoreExpr
 occurAnalyseGlobalExpr expr
   =    -- Top level expr, so no interesting free vars, and
        -- discard occurence info returned
-    expr' where (_, expr') = occurAnalyseExpr emptyIdSet expr
+    snd (occurAnalyseExpr emptyIdSet expr)
 \end{code}
 
 %************************************************************************