[m-rev.] for review: float registers for higher order calls

Peter Wang novalazy at gmail.com
Mon Feb 13 11:33:41 AEDT 2012


On Wed, 8 Feb 2012 15:54:23 +1100 (EST), Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> 
> 
> 
> On Mon, 6 Feb 2012, Peter Wang wrote:
> 
> > Interdiff follows.
> 
> ...
> 
> That looks fine now.

I ran into a problem in grades supporting parallel conjunction.
After the dependent parallel conjunction grade we run

    dead_proc_elim(do_not_elim_opt_imported, !HLDS, _ElimSpecs),

In the float regs pass we end up trying to look up proc_infos which may
have been removed.  For now I've committed it with the following
workaround.  I'll try to investigate it more thoroughly some time.

I accidentally committed my copy of tests/TEST_FLAGS.
I've removed it with cvs rm, but perhaps you want to remove the
file from the Attic.

Peter

diff --git a/compiler/float_regs.m b/compiler/float_regs.m
index a2af908..805d223 100644
--- a/compiler/float_regs.m
+++ b/compiler/float_regs.m
@@ -151,6 +151,7 @@
 :- import_module hlds.hlds_goal.
 :- import_module hlds.hlds_pred.
 :- import_module hlds.instmap.
+:- import_module hlds.passes_aux.
 :- import_module hlds.quantification.
 :- import_module mdbcomp.prim_data.
 :- import_module parse_tree.builtin_lib_types.
@@ -164,6 +165,7 @@
 :- import_module assoc_list.
 :- import_module bool.
 :- import_module int.
+:- import_module io.
 :- import_module map.
 :- import_module maybe.
 :- import_module pair.
@@ -633,12 +635,18 @@ insert_reg_wrappers_goal_2(Goal0, Goal, !InstMap, !Info, !Specs) :-
             MaybeUnifyContext, SymName),
         Context = goal_info_get_context(GoalInfo0),
         insert_reg_wrappers_plain_call(PredId, ProcId, Args0, Args, WrapGoals,
-            !.InstMap, Context, !Info, !Specs),
+            MissingProc, !.InstMap, Context, !Info, !Specs),
+        (
+            MissingProc = no,
         GoalExpr1 = plain_call(PredId, ProcId, Args, Builtin,
             MaybeUnifyContext, SymName),
         finish_call_goal(WrapGoals, GoalExpr1, GoalInfo0, Goal, !InstMap,
             !Info)
     ;
+            MissingProc = yes,
+            Goal = Goal0
+        )
+    ;
         GoalExpr0 = generic_call(GenericCall, Args0, Modes0, _MaybeArgRegs0,
             Determinism),
         (
@@ -1107,18 +1115,33 @@ insert_reg_wrappers_ite(NonLocals, GoalExpr0, GoalExpr, InstMap0, InstMap,
 %-----------------------------------------------------------------------------%
 
 :- pred insert_reg_wrappers_plain_call(pred_id::in, proc_id::in,
-    list(prog_var)::in, list(prog_var)::out, list(hlds_goal)::out,
+    list(prog_var)::in, list(prog_var)::out, list(hlds_goal)::out, bool::out,
     instmap::in, prog_context::in, lambda_info::in, lambda_info::out,
     list(error_spec)::in, list(error_spec)::out) is det.
 
 insert_reg_wrappers_plain_call(PredId, ProcId, Vars0, Vars, WrapGoals,
-        InstMap0, Context, !Info, !Specs) :-
+        MissingProc, InstMap0, Context, !Info, !Specs) :-
     lambda_info_get_module_info(!.Info, ModuleInfo),
-    module_info_pred_proc_info(ModuleInfo, PredId, ProcId, PredInfo, ProcInfo),
+    module_info_pred_info(ModuleInfo, PredId, PredInfo),
+    pred_info_get_procedures(PredInfo, ProcTable),
+    ( map.search(ProcTable, ProcId, ProcInfo) ->
     pred_info_get_arg_types(PredInfo, ArgTypes),
     proc_info_get_argmodes(ProcInfo, ArgModes),
     match_args_for_call(InstMap0, Context, ArgTypes, ArgModes, Vars0, Vars,
-        WrapGoals, !Info, !Specs).
+            WrapGoals, !Info, !Specs),
+        MissingProc = no
+    ;
+        % XXX After the dep_par_conj pass, some dead procedures are removed
+        % but calls to them (from also dead procedures?) remain.
+        trace [compile_time(flag("debug_float_regs")), io(!IO)] (
+            write_proc_progress_message(
+                "% Ignoring call to missing procedure ", PredId, ProcId,
+                ModuleInfo, !IO)
+        ),
+        Vars = Vars0,
+        WrapGoals = [],
+        MissingProc = yes
+    ).
 
 :- pred insert_reg_wrappers_higher_order_call(prog_var::in,
     list(prog_var)::in, list(prog_var)::out, list(mer_mode)::out,
@@ -1209,7 +1232,7 @@ insert_reg_wrappers_foreign_call(PredId, ProcId, ForeignArgs0, ForeignArgs,
         WrapGoals, InstMap0, Context, !Info, !Specs) :-
     Vars0 = list.map(foreign_arg_var, ForeignArgs0),
     insert_reg_wrappers_plain_call(PredId, ProcId, Vars0, Vars, WrapGoals,
-        InstMap0, Context, !Info, !Specs),
+        _MissingProc, InstMap0, Context, !Info, !Specs),
     list.map_corresponding(set_foreign_arg_var, Vars, ForeignArgs0,
         ForeignArgs).
 

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list