[m-rev.] for review: normalize decl_ids in decl_set
Peter Ross
pro at missioncriticalit.com
Fri Nov 1 02:36:59 AEDT 2002
Hi,
For fjh or zs to review.
I checked the decl_id structure looking for anything else that might
need normalizing but couldn't find anything. A second opionion would
be welcome though.
===================================================================
Estimated hours taken: 6
Branches: main
Avoid a bug where duplicate declarations were not being detected.
This prevented the compiler from bootstraping with MSVC in the grade
none.gc.tr.debug.
compiler/llds_out.m:
Normalize the decl_id used to reference the decl_set before
inserting or looking for the decl_id.
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.201
diff -u -r1.201 llds_out.m
--- compiler/llds_out.m 29 Sep 2002 10:30:41 -0000 1.201
+++ compiler/llds_out.m 31 Oct 2002 15:27:07 -0000
@@ -267,7 +267,7 @@
:- import_module parse_tree__mercury_to_mercury.
:- import_module hlds__hlds_pred, hlds__passes_aux.
:- import_module ll_backend__layout, ll_backend__layout_out.
-:- import_module ll_backend__rtti_out.
+:- import_module ll_backend__code_util, ll_backend__rtti_out.
:- import_module ll_backend__exprn_aux, parse_tree__prog_util.
:- import_module backend_libs__rtti, backend_libs__export.
:- import_module backend_libs__c_util, backend_libs__foreign.
@@ -287,10 +287,53 @@
map__init(DeclSet).
decl_set_insert(DeclSet0, DeclId, DeclSet) :-
- map__set(DeclSet0, DeclId, unit, DeclSet).
+ map__set(DeclSet0, normalize(DeclId), unit, DeclSet).
decl_set_is_member(DeclId, DeclSet) :-
- map__search(DeclSet, DeclId, _).
+ map__search(DeclSet, normalize(DeclId), _).
+
+% Normalize the decl_id so that all decl_ids representing the same decl are
+% represented the same way.
+:- func normalize(decl_id) = decl_id.
+
+normalize(DeclId) =
+ ( DeclId = data_addr(layout_addr(LayoutName)) ->
+ data_addr(layout_addr(normalize_layout_name(LayoutName)))
+ ;
+ DeclId
+ ).
+
+:- func normalize_layout_name(layout_name) = layout_name.
+
+normalize_layout_name(label_layout(A, B)) = label_layout(A, B).
+normalize_layout_name(proc_layout(A, B)) = proc_layout(A, B).
+normalize_layout_name(proc_layout_head_var_nums(A))
+ = proc_layout_head_var_nums(A).
+normalize_layout_name(proc_layout_var_names(A)) = proc_layout_var_names(A).
+normalize_layout_name(table_io_decl(A))
+ = table_io_decl(normalize_rtti_proc_label(A)).
+normalize_layout_name(closure_proc_id(A, B, C)) = closure_proc_id(A, B, C).
+normalize_layout_name(file_layout(A, B)) = file_layout(A, B).
+normalize_layout_name(file_layout_line_number_vector(A, B))
+ = file_layout_line_number_vector(A, B).
+normalize_layout_name(file_layout_label_layout_vector(A, B))
+ = file_layout_label_layout_vector(A, B).
+normalize_layout_name(module_layout_string_table(A))
+ = module_layout_string_table(A).
+normalize_layout_name(module_layout_file_vector(A))
+ = module_layout_file_vector(A).
+normalize_layout_name(module_layout_proc_vector(A))
+ = module_layout_proc_vector(A).
+normalize_layout_name(module_layout(A)) = module_layout(A).
+normalize_layout_name(proc_static(A))
+ = proc_static(normalize_rtti_proc_label(A)).
+normalize_layout_name(proc_static_call_sites(A))
+ = proc_static_call_sites(normalize_rtti_proc_label(A)).
+
+:- func normalize_rtti_proc_label(rtti_proc_label) = rtti_proc_label.
+
+normalize_rtti_proc_label(RttiProcLabel)
+ = RttiProcLabel ^ proc_varset := varset__init.
%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
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