Commit 72904630 authored by simonpj's avatar simonpj
Browse files

[project @ 2001-07-25 07:42:23 by simonpj]

---------------------------------------
	Fix a grevious dict-inlining infelicity
	---------------------------------------

This commit fixes an infelicity that must have been there
for a long time.  The problem was that dictionary functions
(arising from instance declarations) were treated as GlobalIds,
and hence no taken account of when doing free variable and dependency
analysis.    As a result, the specialiser was messing up dependency
order, so the program was considerably more complex than it should
be by the time it got to the strictness analyser.

Net result:
	PrelRead.$sreduce :: Integer -> Integer -> (Integer,Integer)
didn't get detected as strict.

Easily fixed, by making DictFunIds into LocalIds (albeit exported ones).
parent 394de04a
......@@ -66,6 +66,7 @@ import DataCon ( DataCon,
splitProductType
)
import Id ( idType, mkGlobalId, mkVanillaGlobal, mkSysLocal,
mkLocalIdWithInfo, setIdNoDiscard,
mkTemplateLocals, mkTemplateLocalsNum,
mkTemplateLocal, idNewStrictness, idName
)
......@@ -665,7 +666,19 @@ mkDictFunId :: Name -- Name to use for the dict fun;
-> Id
mkDictFunId dfun_name clas inst_tyvars inst_tys dfun_theta
= mkVanillaGlobal dfun_name dfun_ty noCafNoTyGenIdInfo
= setIdNoDiscard (mkLocalIdWithInfo dfun_name dfun_ty noCafNoTyGenIdInfo)
-- NB: It's important that dict funs are *local* Ids
-- This ensures that they are taken to account by free-variable finding
-- and dependency analysis (e.g. CoreFVs.exprFreeVars).
-- In particular, if they are globals, the
-- specialiser floats dict uses above their defns, which prevents
-- good simplifications happening.
--
-- It's OK for them to be locals, because we form the instance-env to
-- pass on to the next module (md_insts) in CoreTidy, afer tdying
-- and globalising the top-level Ids.
--
-- BUT Make sure it's an exported Id (setIdNoDiscard) so that it's not dropped!
where
dfun_ty = mkSigmaTy inst_tyvars dfun_theta (mkDictTy clas inst_tys)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment