- unfold_pretty | show_unfold = hsep [ptext unfold_herald, pprIfaceUnfolding rhs]
- | otherwise = empty
-
- unfold_herald = case inline_pragma of
- IMustBeINLINEd -> SLIT("_U_")
- IWantToBeINLINEd -> SLIT("_U_")
- other -> SLIT("_u_")
-
- show_unfold = not implicit_unfolding && -- Not unnecessary
- unfolding_is_ok -- Not dangerous
-
- implicit_unfolding = has_worker ||
- bottomIsGuaranteed strict_info
-
- unfolding_is_ok
- = case inline_pragma of
- IMustBeINLINEd -> definitely_ok_to_unfold
- IWantToBeINLINEd -> definitely_ok_to_unfold
- IDontWantToBeINLINEd -> False
- IMustNotBeINLINEd -> False
- NoPragmaInfo -> case guidance of
- UnfoldNever -> False -- Too big
- other -> definitely_ok_to_unfold
-
- definitely_ok_to_unfold = okToUnfoldInHiFile rhs
- guidance = calcUnfoldingGuidance opt_InterfaceUnfoldThreshold rhs
-
- ------------ Specialisations --------------
- spec_list = specEnvToList (getIdSpecialisation id)
- spec_pretty = hsep (map pp_spec spec_list)
- pp_spec (tyvars, tys, rhs) = hsep [ptext SLIT("_P_"),
- if null tyvars then ptext SLIT("[ ]")
- else brackets (interppSP tyvars),
- -- The lexer interprets "[]" as a CONID. Sigh.
- hsep (map pprParendType tys),
- ptext SLIT("="),
- pprIfaceUnfolding rhs
- ]
-
- ------------ Extra free Ids --------------
- new_needed_ids = (needed_ids `minusIdSet` unitIdSet id) `unionIdSets`
- extra_ids
-
- extra_ids | opt_OmitInterfacePragmas = emptyIdSet
- | otherwise = worker_ids `unionIdSets`
- unfold_ids `unionIdSets`
- spec_ids
-
- worker_ids | has_worker = unitIdSet work_id
- | otherwise = emptyIdSet
-
- spec_ids = foldr add emptyIdSet spec_list
- where
- add (_, _, rhs) = unionIdSets (find_fvs rhs)
-
- unfold_ids | show_unfold = find_fvs rhs
- | otherwise = emptyIdSet
-
- find_fvs expr = free_vars
- where
- free_vars = exprFreeVars interesting expr
- interesting id = isLocallyDefined id &&
- not (omitIfaceSigForId id)