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(..) )
:: 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)
)
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
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)
(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}
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}
%************************************************************************