[m-rev.] [reuse] diff: fix fixpoint table
Nancy Mazur
Nancy.Mazur at cs.kuleuven.ac.be
Wed Mar 28 05:16:52 AEST 2001
Hi,
===================================================================
Estimated hours taken: 1 (+ 6 hours for Peter for locating the bug)
Branches: reuse
Fix the fixpoint table, and record for each entry in the
table, wheteher the information about it is stable or not.
Also minor changes.
fixpoint_table.m:
Record for each entry whether it is stable or not, instead
of only stating global stability (which was wrong).
Add a new predicate to get the final information, yet failing
insteaf of aborting when nothing is found.
pa_run.m:
Also output information about the stability of the analysis-run.
pa_util.m:
Add a new predicate to get the final abstract substitution, but
failing insteaf of aborting if nothing is found.
Index: fixpoint_table.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/fixpoint_table.m,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 fixpoint_table.m
--- fixpoint_table.m 2001/02/28 13:00:41 1.1.2.3
+++ fixpoint_table.m 2001/03/27 19:10:51
@@ -66,6 +66,11 @@
:- pred fp_get_final(K, E, fixpoint_table(K,E)).
:- mode fp_get_final(in, out, in) is det.
+ % Same as fp_get_final, but the predicate fails instead
+ % of aborting when the element is not present.
+:- pred fp_get_final_semidet(K, E, fixpoint_table(K,E)).
+:- mode fp_get_final_semidet(in, out, in) is semidet.
+
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
@@ -79,9 +84,23 @@
keys :: list(K), % list of allowed keys
run :: int, % number of runs
stable :: bool, % is stable (default = yes)
- mapping :: map(K, E)
+ mapping :: map(K, fp_entry(E))
).
+:- type fp_entry(E)
+ ---> entry(
+ bool, % stability: yes = stable, no = unstable
+ E).
+
+:- func fp_entry_init(E) = fp_entry(E).
+:- func fp_entry_stability(fp_entry(E)) = bool.
+:- func fp_entry_elem(fp_entry(E)) = E.
+:- func fp_entry_init(bool, E) = fp_entry(E).
+fp_entry_init(Elem) = entry(no, Elem).
+fp_entry_init(Bool, Elem) = entry(Bool, Elem).
+fp_entry_stability(entry(S, _)) = S.
+fp_entry_elem(entry(_, Elem)) = Elem.
+
fp_init(Init, Ks, ft(Ks, Run, Stable, Map)) :-
Run = 0,
Stable = yes,
@@ -89,7 +108,7 @@
list__foldl(
(pred(K::in, M0::in, M::out) is det :-
Init(K, E),
- map__det_insert(M0, K, E, M)
+ map__det_insert(M0, K, fp_entry_init(E), M)
),
Ks,
Map0,
@@ -100,13 +119,24 @@
fp_which_run(T0) = T0 ^ run.
fp_stable(T) :-
- T ^ stable = yes.
+ map__foldl(
+ pred(_K::in, Entry::in, S0::in, S::out) is det :-
+ (
+ ( S0 = no ->
+ S = no
+ ;
+ S = fp_entry_stability(Entry)
+ )
+ ),
+ T ^ mapping,
+ yes,
+ yes).
fp_add(Equal, Index, Elem, Tin, Tout) :-
Map = Tin ^ mapping,
- Sin = Tin ^ stable,
(
- map__search(Map, Index, TabledElem)
+ map__search(Map, Index, Entry),
+ TabledElem = fp_entry_elem(Entry)
->
(
Equal(TabledElem, Elem)
@@ -127,38 +157,38 @@
% table where not only the reuses are kept (the
% abstract substitution), but also the goal that
% might have changed.
- FinalTabledElem = Elem,
+ FinalTabledElem = fp_entry_init(S, Elem),
map__det_update(Map, Index, FinalTabledElem, MapOut)
;
- S = Sin,
- map__det_insert(Map, Index, Elem, MapOut)
+ % XXX should not occur!
+ map__det_insert(Map, Index, fp_entry_init(Elem), MapOut)
),
- Tout = (Tin ^ mapping := MapOut) ^ stable := S.
+ Tout = (Tin ^ mapping := MapOut).
fp_get(Index, Elem, Tin, Tout) :-
List = Tin ^ keys,
list__member(Index, List), % can fail
Mapin = Tin ^ mapping,
- % Sin = Tin ^ stable,
(
- map__search(Mapin, Index, TabledElem)
+ map__search(Mapin, Index, Entry),
+ TabledElem = fp_entry_elem(Entry)
->
Elem = TabledElem,
- Sout = no,
Mapout = Mapin
;
require__error("(fixpoint_table): key not in map")
- % init(Elem),
- % Sout = no,
- % map__det_insert(Mapin, Index, Elem, Mapout)
),
- Tout = (Tin ^ mapping := Mapout) ^ stable := Sout.
+ Tout = (Tin ^ mapping := Mapout).
fp_get_final(Index, Elem, T) :-
(
- map__search(T ^ mapping, Index, TabledElem)
+ fp_get_final_semidet(Index, TabledElem, T)
->
Elem = TabledElem
;
error("Internal error: fixpoint_table__fp_get_final/2")
).
+
+fp_get_final_semidet(Index, Elem, T):-
+ map__search(T ^ mapping, Index, Entry),
+ Elem = fp_entry_elem(Entry).
Index: pa_run.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_run.m,v
retrieving revision 1.1.2.21
diff -u -r1.1.2.21 pa_run.m
--- pa_run.m 2001/03/23 10:41:30 1.1.2.21
+++ pa_run.m 2001/03/27 19:10:54
@@ -177,6 +177,16 @@
{ PRED_PROC_ID = proc(PredId, ProcId) },
{ pa_util__pa_fixpoint_table_which_run(FPtable0, Run) },
+ {
+ (
+ pa_util__pa_fixpoint_table_get_final_as_semidet(PRED_PROC_ID,
+ TabledAliasAs, FPtable0)
+ ->
+ TabledSize = size(TabledAliasAs)
+ ;
+ TabledSize = 0
+ )
+ },
{ string__int_to_string(Run, SRun)},
{ string__append_list(["% Alias analysing (run ",SRun,") "],
Msg) },
@@ -228,12 +238,17 @@
% io__write_string("\n")
% []
{
+ ( pa_fixpoint_table_all_stable(FPtable) ->
+ Stable = "s" ; Stable = "u"
+ ),
+ string__int_to_string(TabledSize, TabledS),
string__int_to_string(FullSize, FullS),
string__int_to_string(ProjectSize, ProjectS),
string__int_to_string(NormSize, NormS)
},
- io__write_strings(["\t\t: ", FullS, "/", ProjectS, "/",
- NormS]),
+ io__write_strings(["\t\t: ", TabledS, "->",
+ FullS, "/", ProjectS, "/",
+ NormS, "(", Stable, ")"]),
(
{ Widening = bool__yes }
->
Index: pa_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_util.m,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 pa_util.m
--- pa_util.m 2001/03/23 10:41:30 1.1.2.6
+++ pa_util.m 2001/03/27 19:10:54
@@ -57,7 +57,11 @@
pa_fixpoint_table).
:- mode pa_fixpoint_table_get_final_as(in, out, in) is det.
+:- pred pa_fixpoint_table_get_final_as_semidet(pred_proc_id, alias_as,
+ pa_fixpoint_table).
+:- mode pa_fixpoint_table_get_final_as_semidet(in, out, in) is semidet.
+
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- implementation.
@@ -101,6 +105,8 @@
pa_fixpoint_table_get_final_as(PRED_PROC_ID, ALIAS_AS, T):-
fp_get_final(PRED_PROC_ID, ALIAS_AS, T).
+pa_fixpoint_table_get_final_as_semidet(PRED_PROC_ID, ALIAS_AS, T):-
+ fp_get_final_semidet(PRED_PROC_ID, ALIAS_AS, T).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list