Commit bfd0c33d authored by rl@cse.unsw.edu.au's avatar rl@cse.unsw.edu.au
Browse files

Make -f[no-]method-sharing a dynamic flag

We want -Odph to be a dynamic flag and that should imply -fno-method-sharing.
This doesn't add a lot of complexity.
parent 21a2d1db
......@@ -248,6 +248,7 @@ data DynFlag
| Opt_DoEtaReduction
| Opt_CaseMerge
| Opt_UnboxStrictFields
| Opt_MethodSharing
| Opt_DictsCheap
| Opt_RewriteRules
| Opt_Vectorise
......@@ -555,6 +556,8 @@ defaultDynFlags =
Opt_ImplicitPrelude,
Opt_MonomorphismRestriction,
Opt_MethodSharing,
Opt_DoAsmMangling,
Opt_GenManifest,
......@@ -1271,6 +1274,7 @@ fFlags = [
( "do-eta-reduction", Opt_DoEtaReduction ),
( "case-merge", Opt_CaseMerge ),
( "unbox-strict-fields", Opt_UnboxStrictFields ),
( "method-sharing", Opt_MethodSharing ),
( "dicts-cheap", Opt_DictsCheap ),
( "excess-precision", Opt_ExcessPrecision ),
( "asm-mangling", Opt_DoAsmMangling ),
......
......@@ -38,7 +38,6 @@ module StaticFlags (
opt_Parallel,
-- optimisation opts
opt_NoMethodSharing,
opt_NoStateHack,
opt_SpecInlineJoinPoints,
opt_CprOff,
......@@ -317,8 +316,6 @@ opt_SpecInlineJoinPoints :: Bool
opt_SpecInlineJoinPoints = lookUp (fsLit "-fspec-inline-join-points")
opt_NoStateHack :: Bool
opt_NoStateHack = lookUp (fsLit "-fno-state-hack")
opt_NoMethodSharing :: Bool
opt_NoMethodSharing = lookUp (fsLit "-fno-method-sharing")
opt_CprOff :: Bool
opt_CprOff = lookUp (fsLit "-fcpr-off")
-- Switch off CPR analysis in the new demand analyser
......
......@@ -785,7 +785,8 @@ instFun orig fun subst tv_theta_prs
; doStupidChecks fun ty_theta_prs'
-- Now do normal instantiation
; result <- go True fun ty_theta_prs'
; method_sharing <- doptM Opt_MethodSharing
; result <- go method_sharing True fun ty_theta_prs'
; traceTc (text "instFun result" <+> ppr result)
; return result
}
......@@ -793,24 +794,24 @@ instFun orig fun subst tv_theta_prs
subst_pr (tvs, theta)
= (substTyVars subst tvs, substTheta subst theta)
go _ fun [] = do {traceTc (text "go _ fun [] returns" <+> ppr fun) ; return fun }
go _ _ fun [] = do {traceTc (text "go _ _ fun [] returns" <+> ppr fun) ; return fun }
go True (HsVar fun_id) ((tys,theta) : prs)
| want_method_inst theta
go method_sharing True (HsVar fun_id) ((tys,theta) : prs)
| want_method_inst method_sharing theta
= do { traceTc (text "go (HsVar fun_id) ((tys,theta) : prs) | want_method_inst theta")
; meth_id <- newMethodWithGivenTy orig fun_id tys
; go False (HsVar meth_id) prs }
; go method_sharing False (HsVar meth_id) prs }
-- Go round with 'False' to prevent further use
-- of newMethod: see Note [Multiple instantiation]
go _ fun ((tys, theta) : prs)
go method_sharing _ fun ((tys, theta) : prs)
= do { co_fn <- instCall orig tys theta
; traceTc (text "go yields co_fn" <+> ppr co_fn)
; go False (HsWrap co_fn fun) prs }
; go method_sharing False (HsWrap co_fn fun) prs }
-- See Note [No method sharing]
want_method_inst theta = not (null theta) -- Overloaded
&& not opt_NoMethodSharing
want_method_inst method_sharing theta = not (null theta) -- Overloaded
&& method_sharing
\end{code}
Note [Multiple instantiation]
......
......@@ -1207,6 +1207,13 @@
<entry><option>-fno-dicts-strict</option></entry>
</row>
<row>
<entry><option>-fmethod-sharing</option></entry>
<entry>Share specialisations of overloaded functions (default)</entry>
<entry>dynamic</entry>
<entry><option>-fno-method-sharing</option></entry>
</row>
<row>
<entry><option>-fdo-eta-reduction</option></entry>
<entry>Enable eta-reduction. Implied by <option>-O</option>.</entry>
......@@ -2303,12 +2310,6 @@
<entry>static</entry>
<entry>-</entry>
</row>
<row>
<entry><option>-fno-method-sharing</option></entry>
<entry>Don't share specialisations of overloaded functions</entry>
<entry>static</entry>
<entry>-</entry>
</row>
<row>
<entry><option>-fhistory-size</option></entry>
<entry>Set simplification history size</entry>
......
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