[m-dev.] diff: another fix for the context tranformation
Simon Taylor
stayl at cs.mu.OZ.AU
Fri Feb 25 14:45:03 AEDT 2000
Estimated hours taken: 1
Another fix for the context transformation.
compiler/dependency_graph.m:
The context transformation can only be applied to
a single recursive predicate, so don't try to
transform context-transformed SCCs with other SCCs.
tests/valid/context_anc.m:
Add a call to a context transformed predicate from
a magic-sets transformed predicate.
Index: dependency_graph.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/dependency_graph.m,v
retrieving revision 1.45
diff -u -u -r1.45 dependency_graph.m
--- dependency_graph.m 2000/02/21 01:41:29 1.45
+++ dependency_graph.m 2000/02/25 03:10:13
@@ -627,7 +627,17 @@
proc_info::in, aditi_scc_info::in, aditi_scc_info::out) is det.
dependency_graph__process_aditi_proc_info(CurrSCC, PredInfo, ProcInfo) -->
- ( { pred_info_is_exported(PredInfo) } ->
+ (
+ { pred_info_is_exported(PredInfo) }
+ ->
+ aditi_scc_info_add_no_merge_scc(CurrSCC)
+ ;
+ { pred_info_get_markers(PredInfo, Markers) },
+ { check_marker(Markers, context) }
+ ->
+ % The context transformation can only be applied
+ % to a single predicate SCC, so don't merge
+ % other SCCs with a context-transformed SCC.
aditi_scc_info_add_no_merge_scc(CurrSCC)
;
[]
@@ -703,7 +713,8 @@
aditi_dependency_ordering::out) is det.
dependency_graph__merge_aditi_sccs(Info, Ordering) :-
- Info = aditi_scc_info(_, _PredSCC, SCCPred, _, SCCRel, NoMerge, _),
+ Info = aditi_scc_info(ModuleInfo, _PredSCC, SCCPred,
+ _, SCCRel, NoMerge, _),
( relation__tsort(SCCRel, SCCTsort) ->
eqvclass__init(EqvSCCs0),
set__init(MergedSCCs),
@@ -712,26 +723,44 @@
eqvclass__new_element(Eqv0, Elem, Eqv)
)),
list__foldl(AddElement, SCCTsort, EqvSCCs0, EqvSCCs),
- dependency_graph__merge_aditi_sccs_2(SCCTsort, EqvSCCs,
- MergedSCCs, NoMerge, SCCRel, SCCPred, [], Ordering)
+ dependency_graph__merge_aditi_sccs_2(SCCTsort, ModuleInfo,
+ EqvSCCs, MergedSCCs, NoMerge, SCCRel,
+ SCCPred, [], Ordering)
;
error("dependency_graph__merge_aditi_sccs: SCC dependency relation is cyclic")
).
:- pred dependency_graph__merge_aditi_sccs_2(list(scc_id)::in,
- eqvclass(scc_id)::in, set(scc_id)::in, set(scc_id)::in,
- relation(scc_id)::in, scc_pred_map::in,
+ module_info::in, eqvclass(scc_id)::in, set(scc_id)::in,
+ set(scc_id)::in, relation(scc_id)::in, scc_pred_map::in,
aditi_dependency_ordering::in, aditi_dependency_ordering::out) is det.
-dependency_graph__merge_aditi_sccs_2([], _, _, _, _, _, Ordering, Ordering).
-dependency_graph__merge_aditi_sccs_2([SCCid | SCCs0], EqvSCCs0,
+dependency_graph__merge_aditi_sccs_2([], _, _, _, _, _, _, Ordering, Ordering).
+dependency_graph__merge_aditi_sccs_2([SCCid | SCCs0], ModuleInfo, EqvSCCs0,
MergedSCCs0, NoMergeSCCs, SCCRel,
SCCPreds, Ordering0, Ordering) :-
- ( set__member(SCCid, MergedSCCs0) ->
+ (
+ set__member(SCCid, MergedSCCs0)
+ ->
% This SCC has been merged into its parent.
Ordering1 = Ordering0,
EqvSCCs = EqvSCCs0,
SCCs = SCCs0
+ ;
+ map__lookup(SCCPreds, SCCid, SCC0 - EntryPoints),
+ some [PredProcId] (
+ list__member(proc(PredId, _), SCC0),
+ module_info_pred_info(ModuleInfo, PredId, PredInfo),
+ pred_info_get_markers(PredInfo, Markers),
+ check_marker(Markers, context)
+ )
+ ->
+ % Don't merge predicates for which the context
+ % transformation has been requested with other SCCs --
+ % their magic predicates are incompatible.
+ Ordering1 = [aditi_scc([SCC0], EntryPoints) | Ordering0],
+ EqvSCCs = EqvSCCs0,
+ SCCs = SCCs0
;
dependency_graph__get_called_scc_ids(SCCid, SCCRel,
CalledSCCs),
@@ -742,8 +771,9 @@
aditi_scc([SCC0], EntryPoints), SCC),
Ordering1 = [SCC | Ordering0]
),
- dependency_graph__merge_aditi_sccs_2(SCCs, EqvSCCs, MergedSCCs0,
- NoMergeSCCs, SCCRel, SCCPreds, Ordering1, Ordering).
+ dependency_graph__merge_aditi_sccs_2(SCCs, ModuleInfo, EqvSCCs,
+ MergedSCCs0, NoMergeSCCs, SCCRel, SCCPreds,
+ Ordering1, Ordering).
% Find the SCCs called from a given SCC.
:- pred dependency_graph__get_called_scc_ids(scc_id::in, relation(scc_id)::in,
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list