[m-rev.] for review: dead_pred_elim optimization
Peter Ross
pro at missioncriticalit.com
Wed Apr 16 02:30:19 AEST 2003
On Mon, Apr 07, 2003 at 03:25:13PM +1000, Fergus Henderson wrote:
> I'm still seeing a number of test case failures with intermodule
> optimization enabled, in particular for the tests of nested modules,
> and I think this patch is responsible.
>
===================================================================
Estimated hours taken: 2
Branches: main
Fix a bug in the implementation of predicate_table_restrict where we
were assuming that because a procedure was not accessible by
unqualified name that it was also not accessible by partially
qualified names.
compiler/hlds_pred.m:
Replace the marker only_accessible_via_fully_qualifed_name
with the markers not_accessible_by_unqualifed_name and
not_accessible_by_partially_qualified_names.
compiler/hlds_module.m:
Set the new markers in the pred_info and use them in
predicate_table_restrict.
compiler/hlds_out.m:
compiler/intermod.m:
Changes to handle the new markers.
Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.83
diff -u -r1.83 hlds_module.m
--- compiler/hlds_module.m 2 Apr 2003 11:07:14 -0000 1.83
+++ compiler/hlds_module.m 15 Apr 2003 16:18:29 -0000
@@ -1785,26 +1785,32 @@
% new predicate inserted into the table gets its pred_id
% added at the start of the list).
PredicateTable = list__foldr(
- (func(PredId, Table0) = Table :-
- PredInfo = map__lookup(Preds, PredId),
- pred_info_get_markers(PredInfo, Markers),
- (
- check_marker(Markers,
- only_accessible_via_fully_qualifed_name)
- ->
- NeedQual = must_be_qualified,
- MaybeQualInfo = no
- ;
- NeedQual = may_be_unqualified,
- MaybeQualInfo = yes(PartialQualInfo)
- ),
-
- predicate_table_insert_2(Table0,
- yes(PredId), PredInfo,
- NeedQual, MaybeQualInfo,
- _, Table)
-
- ), PredIds, PredicateTable0).
+ (func(PredId, Table0) = Table :-
+ PredInfo = map__lookup(Preds, PredId),
+ pred_info_get_markers(PredInfo, Markers),
+ (
+ check_marker(Markers,
+ not_accessible_by_unqualifed_name)
+ ->
+ NeedQual = must_be_qualified
+ ;
+ NeedQual = may_be_unqualified
+ ),
+ (
+ check_marker(Markers,
+ not_accessible_by_partially_qualified_names)
+ ->
+ MaybeQualInfo = no
+ ;
+ MaybeQualInfo = yes(PartialQualInfo)
+ ),
+
+ predicate_table_insert_2(Table0,
+ yes(PredId), PredInfo,
+ NeedQual, MaybeQualInfo,
+ _, Table)
+
+ ), PredIds, PredicateTable0).
:- pred predicate_table_reset(predicate_table::in, predicate_table::out) is det.
@@ -1911,18 +1917,19 @@
NA = Name / Arity,
multi_map__set(NA_Index0, NA, PredId, NA_Index),
- PredInfo = PredInfo0
+ PredInfo1 = PredInfo0
;
N_Index = N_Index0,
NA_Index = NA_Index0,
- pred_info_get_markers(PredInfo0, Markers0),
- add_marker(Markers0, only_accessible_via_fully_qualifed_name,
- Markers),
- pred_info_set_markers(PredInfo0, Markers, PredInfo)
+ pred_info_get_markers(PredInfo0, MarkersA0),
+ add_marker(MarkersA0, not_accessible_by_unqualifed_name,
+ MarkersA),
+ pred_info_set_markers(PredInfo0, MarkersA, PredInfo1)
),
( MaybeQualInfo = yes(QualInfo) ->
+
% insert partially module-qualified versions
% of the name into the module:name/arity index
get_partial_qualifiers(Module, QualInfo, PartialQuals),
@@ -1930,9 +1937,17 @@
MNAs0::in, MNAs::out] is det,
insert_into_mna_index(AncModule, Name, Arity, PredId,
MNAs0, MNAs)),
- PartialQuals, _, MNA_Index0, MNA_Index1)
+ PartialQuals, _, MNA_Index0, MNA_Index1),
+
+ PredInfo = PredInfo1
;
- MNA_Index1 = MNA_Index0
+ MNA_Index1 = MNA_Index0,
+
+ pred_info_get_markers(PredInfo1, MarkersB0),
+ add_marker(MarkersB0,
+ not_accessible_by_partially_qualified_names,
+ MarkersB),
+ pred_info_set_markers(PredInfo1, MarkersB, PredInfo)
),
% insert the fully-qualified name into the
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.304
diff -u -r1.304 hlds_out.m
--- compiler/hlds_out.m 28 Mar 2003 06:55:12 -0000 1.304
+++ compiler/hlds_out.m 15 Apr 2003 16:18:30 -0000
@@ -1021,8 +1021,10 @@
hlds_out__marker_name(psn, "psn").
hlds_out__marker_name(supp_magic, "supp_magic").
hlds_out__marker_name(context, "context").
-hlds_out__marker_name(only_accessible_via_fully_qualifed_name,
- "only_accessible_via_fully_qualifed_name").
+hlds_out__marker_name(not_accessible_by_unqualifed_name,
+ "not_accessible_by_unqualifed_name").
+hlds_out__marker_name(not_accessible_by_partially_qualified_names,
+ "not_accessible_by_partially_qualified_names").
hlds_out__write_marker(Marker) -->
{ hlds_out__marker_name(Marker, Name) },
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.122
diff -u -r1.122 hlds_pred.m
--- compiler/hlds_pred.m 21 Mar 2003 05:52:06 -0000 1.122
+++ compiler/hlds_pred.m 15 Apr 2003 16:18:30 -0000
@@ -508,9 +508,13 @@
% If the compiler cannot guarantee termination
% then it must give an error message.
- ; only_accessible_via_fully_qualifed_name
- % This predicate can only be accessed by
- % its fully qualified name.
+ ; not_accessible_by_unqualifed_name
+ % This predicate is not accessible by its
+ % unqualified name.
+
+ ; not_accessible_by_partially_qualified_names
+ % This predicate is not accessible by any
+ % partially qualified names.
.
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.137
diff -u -r1.137 intermod.m
--- compiler/intermod.m 21 Mar 2003 05:52:06 -0000 1.137
+++ compiler/intermod.m 15 Apr 2003 16:18:30 -0000
@@ -1837,7 +1837,8 @@
intermod__should_output_marker(generate_inline, _) :-
% This marker should only occur after the magic sets transformation.
error("intermod__should_output_marker: generate_inline").
-intermod__should_output_marker(only_accessible_via_fully_qualifed_name, no).
+intermod__should_output_marker(not_accessible_by_unqualifed_name, no).
+intermod__should_output_marker(not_accessible_by_partially_qualified_names, no).
:- pred get_pragma_foreign_code_vars(list(prog_var)::in,
list(maybe(pair(string, mode)))::in, prog_varset::in,
--------------------------------------------------------------------------
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