[m-rev.] for review: fix lost `impure' goal features
Simon Taylor
stayl at cs.mu.OZ.AU
Fri Feb 28 01:05:05 AEDT 2003
Estimated hours taken: 8
Branches: main, release
Fix bugs in the handling of purity in the optimization passes
(in particular constraint propagation), which caused purity
annotations on goals to be lost. This caused
tests/tabling/unused_args to fail on earth.
compiler/hlds_goal.m:
Make the version of goal_info_init called from
the optimization passes take the purity as an
argument. Previously, callers were constructing
a goal_info then adding the purity, which was
error prone.
compiler/*.m:
Pass the extra argument to goal_info_init.
compiler/polymorphism.m:
Remove a duplicate definition of
hlds_goal__make_int_const_construction.
compiler/magic.m:
Remove some unused code.
tests/hard_coded/purity/Mmakefile:
tests/hard_coded/purity/Mercury.options:
tests/hard_coded/purity/purity_opt.{m,exp}:
Test case.
Index: compiler/accumulator.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/accumulator.m,v
retrieving revision 1.20
diff -u -u -r1.20 accumulator.m
--- compiler/accumulator.m 28 Mar 2002 03:42:40 -0000 1.20
+++ compiler/accumulator.m 25 Feb 2003 14:07:03 -0000
@@ -1855,7 +1855,7 @@
instmap_delta_from_assoc_list([Out - ground(shared, none)],
InstMapDelta),
- goal_info_init(NonLocalVars, InstMapDelta, det, Info),
+ goal_info_init(NonLocalVars, InstMapDelta, det, pure, Info),
Goal = Expr - Info.
@@ -2034,7 +2034,8 @@
goal_list_instmap_delta(GoalList, InstMapDelta),
goal_list_determinism(GoalList, Determinism),
- goal_info_init(NonLocals, InstMapDelta, Determinism, GoalInfo)
+ goal_info_init(NonLocals, InstMapDelta,
+ Determinism, pure, GoalInfo)
;
error("calculate_goal_info: not a conj.")
).
Index: compiler/common.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/common.m,v
retrieving revision 1.66
diff -u -u -r1.66 common.m
--- compiler/common.m 22 Feb 2003 13:18:22 -0000 1.66
+++ compiler/common.m 25 Feb 2003 13:01:19 -0000
@@ -691,7 +691,7 @@
det, no, [], ModuleInfo, Context, GoalExpr - _),
instmap_delta_restrict(InstMapDelta0, NonLocals, InstMapDelta)
),
- goal_info_init(NonLocals, InstMapDelta, det, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, det, pure, GoalInfo),
Goal = GoalExpr - GoalInfo,
common__record_equivalence(ToVar, FromVar, Info0, Info).
Index: compiler/constraint.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/constraint.m,v
retrieving revision 1.49
diff -u -u -r1.49 constraint.m
--- compiler/constraint.m 28 Mar 2002 03:42:49 -0000 1.49
+++ compiler/constraint.m 26 Feb 2003 01:15:41 -0000
@@ -47,9 +47,9 @@
:- import_module hlds__goal_util, hlds__hlds_pred, hlds__hlds_module.
:- import_module hlds__hlds_data, hlds__passes_aux, hlds__goal_form.
+:- import_module check_hlds__purity.
:- import_module check_hlds__mode_util.
:- import_module check_hlds__inst_match.
-:- import_module check_hlds__purity.
:- import_module libs__options, libs__globals.
:- import_module assoc_list, list, require, set, std_util.
@@ -80,7 +80,8 @@
{ goal_list_nonlocals(Goals, NonLocals) },
{ goal_list_instmap_delta(Goals, Delta) },
{ goal_list_determinism(Goals, ConjDetism) },
- { goal_info_init(NonLocals, Delta, ConjDetism, GoalInfo) },
+ { goal_list_purity(Goals, Purity) },
+ { goal_info_init(NonLocals, Delta, ConjDetism, Purity, GoalInfo) },
{ conj_list_to_goal(Goals, GoalInfo, Goal) }.
:- pred constraint__propagate_conj_sub_goal(hlds_goal, list(constraint),
Index: compiler/context.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/context.m,v
retrieving revision 1.5
diff -u -u -r1.5 context.m
--- compiler/context.m 20 Mar 2002 12:36:00 -0000 1.5
+++ compiler/context.m 25 Feb 2003 12:54:59 -0000
@@ -396,7 +396,7 @@
{ list__append(FactoredGoal, Goals, AllGoals) },
{ goal_list_instmap_delta(AllGoals, Delta) },
{ goal_list_determinism(AllGoals, Det) },
- { goal_info_init(AllNonLocals, Delta, Det, MagicRuleInfo) },
+ { goal_info_init(AllNonLocals, Delta, Det, pure, MagicRuleInfo) },
{ conj_list_to_goal(AllGoals, MagicRuleInfo, MagicGoal) },
magic_util__add_to_magic_predicate(PredProcId1, MagicGoal, MagicArgs).
@@ -440,7 +440,7 @@
{ list__append(FactoredGoal, Goals1, AllGoals) },
{ goal_list_instmap_delta(AllGoals, Delta) },
{ goal_list_determinism(AllGoals, Det) },
- { goal_info_init(NonLocals2, Delta, Det, MagicRuleInfo) },
+ { goal_info_init(NonLocals2, Delta, Det, pure, MagicRuleInfo) },
{ conj_list_to_goal(AllGoals, MagicRuleInfo, MagicGoal) },
magic_info_get_curr_pred_proc_id(PredProcId1),
magic_util__add_to_magic_predicate(PredProcId1, MagicGoal, MagicArgs).
@@ -563,7 +563,7 @@
magic_info_get_module_info(ModuleInfo),
{ instmap_delta_from_mode_list(AllInputArgs, AllOutputModes,
ModuleInfo, InstMapDelta) },
- { goal_info_init(NonLocals, InstMapDelta, nondet, GoalInfo) },
+ { goal_info_init(NonLocals, InstMapDelta, nondet, pure, GoalInfo) },
{ MagicCall = call(MagicPredId, MagicProcId, MagicArgs,
not_builtin, no, PredName) - GoalInfo }.
Index: compiler/deep_profiling.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.14
diff -u -u -r1.14 deep_profiling.m
--- compiler/deep_profiling.m 22 Feb 2003 13:18:23 -0000 1.14
+++ compiler/deep_profiling.m 25 Feb 2003 14:05:59 -0000
@@ -1646,7 +1646,7 @@
instmap_delta_from_assoc_list([Var - ground(shared, none)],
InstMapDelta),
Determinism = det,
- goal_info_init(NonLocals, InstMapDelta, Determinism, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, Determinism, pure, GoalInfo),
Goal = unify(Var, functor(ConsId, no, []),
(free -> Ground) - (Ground -> Ground),
construct(Var, ConsId, [], [], construct_statically([]),
@@ -1661,7 +1661,7 @@
NonLocals = set__list_to_set([Var | Args]),
instmap_delta_from_assoc_list([Var - Ground], InstMapDelta),
Determinism = det,
- goal_info_init(NonLocals, InstMapDelta, Determinism, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, Determinism, pure, GoalInfo),
ArgMode = ((free - Ground) -> (Ground - Ground)),
list__duplicate(Length, ArgMode, ArgModes),
Goal = unify(Var, functor(ConsId, no, Args),
@@ -1716,24 +1716,21 @@
= hlds_goal_info.
impure_init_goal_info(NonLocals, InstMapDelta, Determinism) = GoalInfo :-
- goal_info_init(NonLocals, InstMapDelta, Determinism, GoalInfo0),
- goal_info_add_feature(GoalInfo0, impure, GoalInfo).
+ goal_info_init(NonLocals, InstMapDelta, Determinism, impure, GoalInfo).
:- func impure_reachable_init_goal_info(set(prog_var), determinism)
= hlds_goal_info.
impure_reachable_init_goal_info(NonLocals, Determinism) = GoalInfo :-
instmap_delta_init_reachable(InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, Determinism, GoalInfo0),
- goal_info_add_feature(GoalInfo0, impure, GoalInfo).
+ goal_info_init(NonLocals, InstMapDelta, Determinism, impure, GoalInfo).
:- func impure_unreachable_init_goal_info(set(prog_var), determinism)
= hlds_goal_info.
impure_unreachable_init_goal_info(NonLocals, Determinism) = GoalInfo :-
instmap_delta_init_unreachable(InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, Determinism, GoalInfo0),
- goal_info_add_feature(GoalInfo0, impure, GoalInfo).
+ goal_info_init(NonLocals, InstMapDelta, Determinism, impure, GoalInfo).
:- func goal_info_add_nonlocals_make_impure(hlds_goal_info, set(prog_var))
= hlds_goal_info.
@@ -1748,6 +1745,6 @@
fail_goal_info = GoalInfo :-
instmap_delta_init_unreachable(InstMapDelta),
- goal_info_init(set__init, InstMapDelta, failure, GoalInfo).
+ goal_info_init(set__init, InstMapDelta, failure, pure, GoalInfo).
%-----------------------------------------------------------------------------%
Index: compiler/deforest.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/deforest.m,v
retrieving revision 1.27
diff -u -u -r1.27 deforest.m
--- compiler/deforest.m 29 Apr 2002 05:50:40 -0000 1.27
+++ compiler/deforest.m 26 Feb 2003 01:20:27 -0000
@@ -1209,7 +1209,8 @@
ModuleInfo, InstMapDelta) },
{ proc_info_interface_determinism(ProcInfo, Detism) },
{ set__list_to_set(Args, NonLocals) },
- { goal_info_init(NonLocals, InstMapDelta, Detism, GoalInfo) },
+ { pred_info_get_purity(CalledPredInfo, Purity) },
+ { goal_info_init(NonLocals, InstMapDelta, Detism, Purity, GoalInfo) },
{ pred_info_module(CalledPredInfo, PredModule) },
{ pred_info_name(CalledPredInfo, PredName) },
@@ -1261,7 +1262,8 @@
goal_list_determinism(DeforestConj, Detism),
goal_list_instmap_delta(DeforestConj, InstMapDelta0),
instmap_delta_restrict(InstMapDelta0, NonLocals, InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, Detism, ConjInfo0),
+ goal_list_purity(DeforestConj, Purity),
+ goal_info_init(NonLocals, InstMapDelta, Detism, Purity, ConjInfo0),
% Give the conjunction a context so that the generated predicate
% name points to the location of the first goal.
@@ -1661,7 +1663,10 @@
{ goal_list_determinism([EarlierGoal | BetweenGoals], Detism0) },
{ goal_info_get_determinism(LaterInfo, Detism1) },
{ det_conjunction_detism(Detism0, Detism1, Detism) },
- { goal_info_init(NonLocals, Delta, Detism, GoalInfo) },
+ { goal_list_purity([EarlierGoal | BetweenGoals], Purity0) },
+ { infer_goal_info_purity(LaterInfo, Purity1) },
+ { worst_purity(Purity0, Purity1, Purity) },
+ { goal_info_init(NonLocals, Delta, Detism, Purity, GoalInfo) },
{ Goal2 = GoalExpr - GoalInfo },
pd_info_get_module_info(ModuleInfo),
@@ -1736,7 +1741,8 @@
{ goal_list_instmap_delta(Goals, Delta0) },
{ instmap_delta_restrict(Delta0, NonLocals, Delta) },
{ goal_list_determinism(Goals, Detism) },
- { goal_info_init(NonLocals, Delta, Detism, GoalInfo) },
+ { goal_list_purity(Goals, Purity) },
+ { goal_info_init(NonLocals, Delta, Detism, Purity, GoalInfo) },
{ Goal = conj(Goals) - GoalInfo }.
%-----------------------------------------------------------------------------%
Index: compiler/goal_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/goal_util.m,v
retrieving revision 1.80
diff -u -u -r1.80 goal_util.m
--- compiler/goal_util.m 22 Feb 2003 13:18:23 -0000 1.80
+++ compiler/goal_util.m 26 Feb 2003 01:18:10 -0000
@@ -1031,7 +1031,8 @@
instmap_delta_bind_var_to_functor(Var, VarType, ConsId, InstMap,
ExtraInstMapDelta0, ExtraInstMapDelta,
ModuleInfo0, ModuleInfo),
- goal_info_init(NonLocals, ExtraInstMapDelta, semidet, ExtraGoalInfo),
+ goal_info_init(NonLocals, ExtraInstMapDelta,
+ semidet, pure, ExtraGoalInfo),
% Conjoin the test and the rest of the case.
goal_to_conj_list(CaseGoal, CaseGoalConj),
@@ -1047,7 +1048,9 @@
CaseInstMapDelta, InstMapDelta),
goal_info_get_determinism(CaseGoalInfo, CaseDetism0),
det_conjunction_detism(semidet, CaseDetism0, Detism),
- goal_info_init(CaseNonLocals, InstMapDelta, Detism, CombinedGoalInfo),
+ infer_goal_info_purity(CaseGoalInfo, CasePurity),
+ goal_info_init(CaseNonLocals, InstMapDelta,
+ Detism, CasePurity, CombinedGoalInfo),
Disjunct = conj(GoalList) - CombinedGoalInfo.
%-----------------------------------------------------------------------------%
@@ -1088,7 +1091,9 @@
instmap_delta_init_reachable(NegCondDelta)
),
goal_info_get_nonlocals(CondInfo, CondNonLocals),
- goal_info_init(CondNonLocals, NegCondDelta, NegCondDet, NegCondInfo),
+ infer_goal_info_purity(CondInfo, CondPurity),
+ goal_info_init(CondNonLocals, NegCondDelta, NegCondDet, CondPurity,
+ NegCondInfo),
goal_util__compute_disjunct_goal_info(not(Cond) - NegCondInfo, Else,
GoalInfo, NegCondElseInfo),
@@ -1119,8 +1124,10 @@
goal_info_get_determinism(GoalInfo2, Detism2),
det_conjunction_detism(Detism1, Detism2, CombinedDetism),
+ goal_list_purity([Goal1, Goal2], CombinedPurity),
+
goal_info_init(CombinedNonLocals, CombinedDelta,
- CombinedDetism, CombinedInfo).
+ CombinedDetism, CombinedPurity, CombinedInfo).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -1237,7 +1244,9 @@
;
instmap_delta_from_assoc_list(InstMap, InstMapDelta)
),
- goal_info_init(NonLocals, InstMapDelta, Detism, Context,
+ module_info_pred_info(Module, PredId, PredInfo),
+ pred_info_get_purity(PredInfo, Purity),
+ goal_info_init(NonLocals, InstMapDelta, Detism, Purity, Context,
CallGoalInfo0),
(
MaybeFeature = yes(Feature),
Index: compiler/higher_order.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.101
diff -u -u -r1.101 higher_order.m
--- compiler/higher_order.m 22 Feb 2003 13:18:23 -0000 1.101
+++ compiler/higher_order.m 25 Feb 2003 14:11:44 -0000
@@ -958,7 +958,7 @@
instmap_delta_init_reachable(InstMapDelta0),
instmap_delta_insert(InstMapDelta0, ResultVar,
ground(shared, none), InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, det, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, det, pure, GoalInfo),
CallGoal = call(PredId, ProcId, CallArgs, not_builtin,
MaybeContext, SymName) - GoalInfo,
get_typeclass_info_args_2(TypeClassInfoVar, PredId, ProcId, SymName,
@@ -1955,7 +1955,7 @@
InstMapDelta),
Detism = det,
goal_info_init(NonLocals, InstMapDelta,
- Detism, Context, GoalInfo),
+ Detism, pure, Context, GoalInfo),
Goal = conj([CastGoal1, CastGoal2,
Call - GoalInfo]),
Info = Info0 ^ proc_info := ProcInfo
@@ -2009,7 +2009,7 @@
(In - In),
simple_test(UnwrappedArg1, UnwrappedArg2),
unify_context(explicit, [])),
- goal_info_init(NonLocals, InstMapDelta, Detism,
+ goal_info_init(NonLocals, InstMapDelta, Detism, pure,
Context, GoalInfo),
Goal = conj([ExtractGoal1, ExtractGoal2,
SpecialGoal - GoalInfo]),
@@ -2037,7 +2037,7 @@
SpecialProcId, NewCallArgs,
not_builtin, MaybeContext, SymName),
goal_info_init(NonLocals, InstMapDelta, Detism,
- Context, GoalInfo),
+ pure, Context, GoalInfo),
Goal = conj([ExtractGoal1, ExtractGoal2,
SpecialGoal - GoalInfo]),
Info = Info0 ^ proc_info := ProcInfo2
@@ -2055,7 +2055,7 @@
SpecialProcId, NewCallArgs,
not_builtin, MaybeContext, SymName),
goal_info_init(NonLocals, InstMapDelta, Detism,
- Context, GoalInfo),
+ pure, Context, GoalInfo),
Goal = conj([ExtractGoal1, CastGoal1,
ExtractGoal2, CastGoal2,
SpecialGoal - GoalInfo]),
@@ -2207,7 +2207,7 @@
set__list_to_set([Arg, CastArg], NonLocals),
instmap_delta_from_assoc_list([CastArg - ground(shared, none)],
InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, det, Context, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, det, pure, Context, GoalInfo),
Goal = call(PredId, ProcId, [Arg, CastArg], inline_builtin,
no, qualified(MercuryBuiltin, "unsafe_type_cast")) - GoalInfo.
@@ -2228,7 +2228,7 @@
% This will be recomputed later.
instmap_delta_from_assoc_list([UnwrappedArg - ground(shared, none)],
InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, det, Context, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, det, pure, Context, GoalInfo),
Goal = unify(Arg, functor(ConsId, no, [UnwrappedArg]), In - Out,
deconstruct(Arg, ConsId, [UnwrappedArg], UniModes,
cannot_fail, no),
@@ -3008,7 +3008,7 @@
instmap_delta_from_assoc_list([LVar - ConstInst],
ConstInstMapDelta),
goal_info_init(ConstNonLocals, ConstInstMapDelta,
- det, ConstGoalInfo),
+ det, pure, ConstGoalInfo),
RHS = functor(ConsId, no, CurriedHeadVars1),
UniMode = (free -> ConstInst) - (ConstInst -> ConstInst),
ConstGoal = unify(LVar, RHS, UniMode,
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.101
diff -u -u -r1.101 hlds_goal.m
--- compiler/hlds_goal.m 4 Feb 2003 06:09:47 -0000 1.101
+++ compiler/hlds_goal.m 26 Feb 2003 03:22:33 -0000
@@ -615,12 +615,12 @@
:- pred goal_info_init(prog_context, hlds_goal_info).
:- mode goal_info_init(in, out) is det.
-:- pred goal_info_init(set(prog_var), instmap_delta, determinism,
+:- pred goal_info_init(set(prog_var), instmap_delta, determinism, purity,
hlds_goal_info).
-:- mode goal_info_init(in, in, in, out) is det.
+:- mode goal_info_init(in, in, in, in, out) is det.
:- pred goal_info_init(set(prog_var)::in, instmap_delta::in, determinism::in,
- prog_context::in, hlds_goal_info::out) is det.
+ purity::in, prog_context::in, hlds_goal_info::out) is det.
% Instead of recording the liveness of every variable at every
% part of the goal, we just keep track of the initial liveness
@@ -1107,6 +1107,7 @@
:- implementation.
+:- import_module check_hlds__purity.
:- import_module check_hlds__det_analysis, parse_tree__prog_util.
:- import_module check_hlds__type_util.
:- import_module require, string, term, varset.
@@ -1228,18 +1229,20 @@
goal_info_init(GoalInfo0),
goal_info_set_context(GoalInfo0, Context, GoalInfo).
-goal_info_init(NonLocals, InstMapDelta, Detism, GoalInfo) :-
+goal_info_init(NonLocals, InstMapDelta, Detism, Purity, GoalInfo) :-
goal_info_init(GoalInfo0),
goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo1),
goal_info_set_instmap_delta(GoalInfo1, InstMapDelta, GoalInfo2),
- goal_info_set_determinism(GoalInfo2, Detism, GoalInfo).
+ goal_info_set_determinism(GoalInfo2, Detism, GoalInfo3),
+ add_goal_info_purity_feature(GoalInfo3, Purity, GoalInfo).
-goal_info_init(NonLocals, InstMapDelta, Detism, Context, GoalInfo) :-
+goal_info_init(NonLocals, InstMapDelta, Detism, Purity, Context, GoalInfo) :-
goal_info_init(GoalInfo0),
goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo1),
goal_info_set_instmap_delta(GoalInfo1, InstMapDelta, GoalInfo2),
goal_info_set_determinism(GoalInfo2, Detism, GoalInfo3),
- goal_info_set_context(GoalInfo3, Context, GoalInfo).
+ goal_info_set_context(GoalInfo3, Context, GoalInfo4),
+ add_goal_info_purity_feature(GoalInfo4, Purity, GoalInfo).
goal_info_get_determinism(GoalInfo, GoalInfo ^ determinism).
@@ -1519,20 +1522,16 @@
%-----------------------------------------------------------------------------%
true_goal(conj([]) - GoalInfo) :-
- goal_info_init(GoalInfo0),
- goal_info_set_determinism(GoalInfo0, det, GoalInfo1),
instmap_delta_init_reachable(InstMapDelta),
- goal_info_set_instmap_delta(GoalInfo1, InstMapDelta, GoalInfo).
+ goal_info_init(set__init, InstMapDelta, det, pure, GoalInfo).
true_goal(Context, Goal - GoalInfo) :-
true_goal(Goal - GoalInfo0),
goal_info_set_context(GoalInfo0, Context, GoalInfo).
fail_goal(disj([]) - GoalInfo) :-
- goal_info_init(GoalInfo0),
- goal_info_set_determinism(GoalInfo0, failure, GoalInfo1),
instmap_delta_init_unreachable(InstMapDelta),
- goal_info_set_instmap_delta(GoalInfo1, InstMapDelta, GoalInfo).
+ goal_info_init(set__init, InstMapDelta, failure, pure, GoalInfo).
fail_goal(Context, Goal - GoalInfo) :-
fail_goal(Goal - GoalInfo0),
@@ -1720,7 +1719,7 @@
set__singleton_set(NonLocals, Var),
instmap_delta_init_reachable(InstMapDelta0),
instmap_delta_insert(InstMapDelta0, Var, Inst, InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, det, GoalInfo).
+ goal_info_init(NonLocals, InstMapDelta, det, pure, GoalInfo).
%-----------------------------------------------------------------------------%
Index: compiler/magic.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/magic.m,v
retrieving revision 1.32
diff -u -u -r1.32 magic.m
--- compiler/magic.m 27 Jan 2003 09:20:46 -0000 1.32
+++ compiler/magic.m 25 Feb 2003 12:58:26 -0000
@@ -1068,7 +1068,7 @@
HOCallNonLocals),
instmap_delta_from_mode_list(InputArgs, MagicArgModes,
ModuleInfo0, HOCallDelta),
- goal_info_init(HOCallNonLocals, HOCallDelta, nondet,
+ goal_info_init(HOCallNonLocals, HOCallDelta, nondet, pure,
InputGoalInfo),
list__length(InputArgs, Arity),
InputGoal = generic_call(
@@ -1116,7 +1116,7 @@
ModuleInfo1, GoalDelta),
set__list_to_set([ClosureVar | OutputArgs],
GoalNonLocals),
- goal_info_init(GoalNonLocals, GoalDelta, nondet, GoalInfo),
+ goal_info_init(GoalNonLocals, GoalDelta, nondet, pure, GoalInfo),
conj_list_to_goal([InputGoal, CallGoal | Tests], GoalInfo,
JoinGoal),
proc_info_set_goal(JoinProcInfo4, JoinGoal, JoinProcInfo),
@@ -1229,7 +1229,8 @@
{ instmap_delta_from_mode_list(DoCallAditiArgs, DoCallAditiArgModes,
ModuleInfo1, GoalDelta) },
{ proc_info_inferred_determinism(CProcInfo2, Detism) },
- { goal_info_init(CallNonLocals, GoalDelta, Detism, CallGoalInfo) },
+ { goal_info_init(CallNonLocals, GoalDelta,
+ Detism, pure, CallGoalInfo) },
{ pred_info_get_is_pred_or_func(CPredInfo1, CPredOrFunc) },
{ pred_info_module(CPredInfo1, CPredModule) },
{ pred_info_name(CPredInfo1, CPredName) },
@@ -1243,7 +1244,8 @@
{ list__append(TypeInfoGoals, [DoCallAditiGoal], Goals) },
{ set__list_to_set(HeadVars, GoalNonLocals) },
{ goal_list_determinism(Goals, GoalDetism) },
- { goal_info_init(GoalNonLocals, GoalDelta, GoalDetism, GoalInfo) },
+ { goal_info_init(GoalNonLocals, GoalDelta, GoalDetism,
+ pure, GoalInfo) },
{ Goal = conj(Goals) - GoalInfo },
{ proc_info_set_goal(CProcInfo2, Goal, CProcInfo) },
@@ -1266,24 +1268,6 @@
ProcInfo0, ProcInfo, ModuleInfo) },
magic_info_set_module_info(ModuleInfo).
-:- pred magic__make_const((type)::in, cons_id::in, prog_var::out,
- hlds_goal::out, proc_info::in, proc_info::out) is det.
-
-magic__make_const(Type, ConsId, Var, Goal, ProcInfo0, ProcInfo) :-
- proc_info_create_var_from_type(ProcInfo0, Type, no, Var, ProcInfo),
- set__singleton_set(NonLocals, Var),
- Inst = bound(unique, [functor(ConsId, [])]),
- instmap_delta_init_reachable(Delta0),
- instmap_delta_insert(Delta0, Var, Inst, Delta),
- UnifyMode = (free -> Inst) - (Inst -> Inst),
- RLExprnId = no,
- Uni = construct(Var, ConsId, [], [],
- construct_dynamically, cell_is_unique, RLExprnId),
- Context = unify_context(explicit, []),
- goal_info_init(NonLocals, Delta, det, GoalInfo),
- Goal = unify(Var, functor(ConsId, no, []), UnifyMode, Uni, Context) -
- GoalInfo.
-
%-----------------------------------------------------------------------------%
% Allocate a predicate to collect the input for the current predicate.
@@ -1354,7 +1338,7 @@
OutputInsts0, InstAL0) },
{ instmap_delta_from_assoc_list(InstAL0, InstMapDelta0) },
{ goal_info_init(NonLocals0, InstMapDelta0,
- nondet, GoalInfo0) },
+ nondet, pure, GoalInfo0) },
{ list__length(InputArgs0, Arity) },
{ Goal0 = generic_call(
higher_order(CurrPredVar, (pure), predicate, Arity),
@@ -1370,7 +1354,7 @@
{ instmap_delta_from_assoc_list(InstAL, InstMapDelta) },
{ set__list_to_set([CurrPredVar | InputArgs],
NonLocals) },
- { goal_info_init(NonLocals, InstMapDelta, nondet,
+ { goal_info_init(NonLocals, InstMapDelta, nondet, pure,
GoalInfo) },
{ conj_list_to_goal([Goal0 | Assigns],
GoalInfo, Goal) }
@@ -1448,7 +1432,7 @@
assign(Arg, Arg0), unify_context(explicit, [])),
set__list_to_set([Arg0, Arg], NonLocals),
instmap_delta_from_assoc_list([Arg - Inst], Delta),
- goal_info_init(NonLocals, Delta, det, GoalInfo),
+ goal_info_init(NonLocals, Delta, det, pure, GoalInfo),
magic__create_assignments(ModuleInfo, ArgsAL, Modes, Assigns).
%-----------------------------------------------------------------------------%
@@ -1641,7 +1625,7 @@
{ Inst = ground(shared, none) },
{ set__list_to_set([Arg, NewArg], NonLocals) },
{ instmap_delta_from_assoc_list([NewArg - Inst], Delta) },
- { goal_info_init(NonLocals, Delta, det, GoalInfo) },
+ { goal_info_init(NonLocals, Delta, det, pure, GoalInfo) },
{ ExtraGoal = unify(NewArg, var(Arg), OutMode - InMode,
assign(NewArg, Arg), unify_context(explicit, []))
- GoalInfo },
@@ -1957,7 +1941,7 @@
magic_info_get_module_info(ModuleInfo),
{ instmap_delta_from_mode_list(InputArgs, MagicOutputModes,
ModuleInfo, InstMapDelta) },
- { goal_info_init(NonLocals, InstMapDelta, nondet, GoalInfo) },
+ { goal_info_init(NonLocals, InstMapDelta, nondet, pure, GoalInfo) },
{ MagicCall = call(MagicPredId, MagicProcId, MagicArgs,
not_builtin, no, PredName) - GoalInfo }.
Index: compiler/magic_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/magic_util.m,v
retrieving revision 1.25
diff -u -u -r1.25 magic_util.m
--- compiler/magic_util.m 27 Jan 2003 09:20:46 -0000 1.25
+++ compiler/magic_util.m 25 Feb 2003 12:59:03 -0000
@@ -420,7 +420,7 @@
InnerNonLocals, InnerDelta) },
{ goal_list_determinism(NegGoals, InnerDet) },
{ goal_info_init(InnerNonLocals, InnerDelta,
- InnerDet, InnerInfo) },
+ InnerDet, pure, InnerInfo) },
{ conj_list_to_goal(NegGoals, InnerInfo, InnerConj) },
{ list__append(BeforeGoals, [not(InnerConj) - NegGoalInfo],
@@ -611,7 +611,7 @@
set__list_to_set([Var, OutputVar], NonLocals),
instmap_delta_init_reachable(InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, semidet, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, semidet, pure, GoalInfo),
( type_is_atomic(VarType, ModuleInfo) ->
%
% The type is a builtin, so create a simple_test unification.
@@ -843,7 +843,8 @@
{ instmap_delta_init_reachable(InstMapDelta0) },
{ instmap_delta_insert(InstMapDelta0, InputVar, LambdaInst,
InstMapDelta) },
- { goal_info_init(NonLocals, InstMapDelta, det, GoalInfo) },
+ { goal_info_init(NonLocals, InstMapDelta,
+ det, pure, GoalInfo) },
{ InputGoal = unify(InputVar, Rhs, UnifyMode,
Unify, UnifyContext) - GoalInfo }
@@ -1044,7 +1045,7 @@
{ goal_list_instmap_delta(Goals, Delta0) },
{ set__list_to_set(SuppArgs, SuppArgSet) },
{ instmap_delta_restrict(Delta0, SuppArgSet, Delta) },
- { goal_info_init(SuppArgSet, Delta, nondet, GoalInfo) },
+ { goal_info_init(SuppArgSet, Delta, nondet, pure, GoalInfo) },
%
% Verify that the supplementary predicate does not have any partially
Index: compiler/ml_code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.66
diff -u -u -r1.66 ml_code_util.m
--- compiler/ml_code_util.m 14 Feb 2003 09:58:39 -0000 1.66
+++ compiler/ml_code_util.m 25 Feb 2003 14:06:46 -0000
@@ -2225,7 +2225,7 @@
{ NonLocals = set__union_list(NonLocalsList) },
{ instmap_delta_from_assoc_list([TypeInfoVar - ground(shared, none)],
InstMapDelta) },
- { goal_info_init(NonLocals, InstMapDelta, det, GoalInfo) },
+ { goal_info_init(NonLocals, InstMapDelta, det, impure, GoalInfo) },
{ conj_list_to_goal(HLDS_TypeInfoGoals, GoalInfo, Conj) },
% Convert this HLDS code to MLDS
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.232
diff -u -u -r1.232 polymorphism.m
--- compiler/polymorphism.m 22 Feb 2003 13:18:26 -0000 1.232
+++ compiler/polymorphism.m 25 Feb 2003 13:13:40 -0000
@@ -2395,9 +2395,9 @@
poly_info_get_varset(Info2, VarSet2),
poly_info_get_var_types(Info2, VarTypes2),
- polymorphism__make_count_var(SuperClassIndex, VarSet2,
- VarTypes2, IndexVar, IndexGoal, VarSet,
- VarTypes),
+ make_int_const_construction(SuperClassIndex,
+ yes("SuperClassIndex"), IndexGoal, IndexVar,
+ VarTypes2, VarTypes, VarSet2, VarSet),
poly_info_set_varset_and_types(VarSet, VarTypes,
Info2, Info),
@@ -2481,7 +2481,7 @@
set__list_to_set([BaseVar], NonLocals),
instmap_delta_from_assoc_list([BaseVar - ground(shared, none)],
InstmapDelta),
- goal_info_init(NonLocals, InstmapDelta, det, BaseGoalInfo),
+ goal_info_init(NonLocals, InstmapDelta, det, pure, BaseGoalInfo),
BaseGoal = BaseUnify - BaseGoalInfo,
@@ -2812,9 +2812,9 @@
% type_ctor_info
( IsHigherOrderOrTuple = yes ->
list__length(ArgTypeInfoVars, PredArity),
- polymorphism__make_count_var(PredArity,
- VarSet0, VarTypes0, ArityVar, ArityGoal,
- VarSet1, VarTypes1),
+ make_int_const_construction(PredArity, yes("PredArity"),
+ ArityGoal, ArityVar, VarTypes0, VarTypes1,
+ VarSet0, VarSet1),
polymorphism__init_type_info_var(Type,
[BaseVar, ArityVar | ArgTypeInfoVars], "type_info",
VarSet1, VarTypes1, Var, TypeInfoGoal,
@@ -2843,50 +2843,6 @@
ExtraGoals = ExtraGoals0
).
- % Create a unification `CountVar = <NumTypeArgs>'
-
-:- pred polymorphism__make_count_var(int, prog_varset, map(prog_var, type),
- prog_var, hlds_goal, prog_varset, map(prog_var, type)).
-:- mode polymorphism__make_count_var(in, in, in, out, out, out, out) is det.
-
-polymorphism__make_count_var(NumTypeArgs, VarSet0, VarTypes0,
- CountVar, CountGoal, VarSet, VarTypes) :-
- varset__new_var(VarSet0, CountVar, VarSet1),
- varset__name_var(VarSet1, CountVar, "TypeArity", VarSet),
- construct_type(unqualified("int") - 0, [], IntType),
- map__set(VarTypes0, CountVar, IntType, VarTypes),
- polymorphism__init_with_int_constant(CountVar, NumTypeArgs, CountGoal).
-
- % Create a construction unification `Var = <Num>'
- % where Var is a freshly introduced variable and Num is an
- % integer constant.
-
-:- pred polymorphism__init_with_int_constant(prog_var, int, hlds_goal).
-:- mode polymorphism__init_with_int_constant(in, in, out) is det.
-
-polymorphism__init_with_int_constant(CountVar, Num, CountUnifyGoal) :-
-
- CountConsId = int_const(Num),
- RLExprnId = no,
- CountUnification = construct(CountVar, CountConsId, [], [],
- construct_dynamically, cell_is_shared, RLExprnId),
-
- CountTerm = functor(CountConsId, no, []),
- CountInst = bound(unique, [functor(int_const(Num), [])]),
- CountUnifyMode = (free -> CountInst) - (CountInst -> CountInst),
- CountUnifyContext = unify_context(explicit, []),
- % XXX the UnifyContext is wrong
- CountUnify = unify(CountVar, CountTerm, CountUnifyMode,
- CountUnification, CountUnifyContext),
-
- % create a goal_info for the unification
-
- set__singleton_set(CountNonLocals, CountVar),
- instmap_delta_from_assoc_list([CountVar - CountInst], InstmapDelta),
- goal_info_init(CountNonLocals, InstmapDelta, det, CountGoalInfo),
-
- CountUnifyGoal = CountUnify - CountGoalInfo.
-
polymorphism__get_special_proc(Type, SpecialPredId, ModuleInfo,
PredName, PredId, ProcId) :-
classify_type(Type, ModuleInfo, TypeCategory),
@@ -2987,7 +2943,7 @@
instmap_delta_from_assoc_list(
[TypeInfoVar - bound(unique, [functor(InstConsId, ArgInsts)])],
InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, det, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, det, pure, GoalInfo),
TypeInfoGoal = Unify - GoalInfo.
@@ -3037,7 +2993,7 @@
set__list_to_set([TypeCtorInfoVar], NonLocals),
instmap_delta_from_assoc_list([TypeCtorInfoVar - ground(shared, none)],
InstmapDelta),
- goal_info_init(NonLocals, InstmapDelta, det, GoalInfo),
+ goal_info_init(NonLocals, InstmapDelta, det, pure, GoalInfo),
TypeCtorInfoGoal = Unify - GoalInfo.
@@ -3141,8 +3097,8 @@
ModuleInfo, Goals, TypeInfoVar,
VarSet0, VarTypes0, VarSet, VarTypes) :-
- polymorphism__make_count_var(Index, VarSet0, VarTypes0, IndexVar,
- IndexGoal, VarSet1, VarTypes1),
+ make_int_const_construction(Index, yes("TypeInfoIndex"),
+ IndexGoal, IndexVar, VarTypes0, VarTypes1, VarSet0, VarSet1),
polymorphism__new_type_info_var_raw(term__variable(TypeVar),
"type_info", typeinfo_prefix, VarSet1, VarTypes1,
@@ -3461,7 +3417,8 @@
set__list_to_set(HeadVars0, NonLocals),
instmap_delta_from_mode_list(HeadVars0, Modes0, ModuleInfo0,
InstmapDelta),
- goal_info_init(NonLocals, InstmapDelta, Detism, GoalInfo),
+ pred_info_get_purity(PredInfo0, Purity),
+ goal_info_init(NonLocals, InstmapDelta, Detism, Purity, GoalInfo),
BodyGoal = BodyGoalExpr - GoalInfo,
proc_info_set_goal(ProcInfo0, BodyGoal, ProcInfo),
Index: compiler/rl_out.pp
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rl_out.pp,v
retrieving revision 1.18
diff -u -u -r1.18 rl_out.pp
--- compiler/rl_out.pp 20 Mar 2002 12:35:47 -0000 1.18
+++ compiler/rl_out.pp 26 Feb 2003 05:08:46 -0000
@@ -1306,10 +1306,10 @@
NegDetism = semidet
},
{ instmap_delta_init_reachable(IMDelta) },
- { goal_info_init(NonLocals, IMDelta, Detism0,
+ { goal_info_init(NonLocals, IMDelta, Detism0, pure,
GoalInfo) },
{ conj_list_to_goal(Goals0, GoalInfo, Conj) },
- { goal_info_init(NonLocals, IMDelta, NegDetism,
+ { goal_info_init(NonLocals, IMDelta, NegDetism, pure,
NegGoalInfo) },
{ NegGoal = not(Conj) - NegGoalInfo },
{ ProjectCond = ProjectCond0 ^ goal := [NegGoal] },
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.111
diff -u -u -r1.111 simplify.m
--- compiler/simplify.m 22 Feb 2003 13:18:28 -0000 1.111
+++ compiler/simplify.m 25 Feb 2003 13:17:20 -0000
@@ -674,11 +674,9 @@
ModuleInfo, Info3),
goal_info_get_determinism(GoalInfo0, CaseDetism),
det_conjunction_detism(semidet, CaseDetism, Detism),
- goal_info_init(NonLocals, InstMapDelta, Detism,
- CombinedGoalInfo0),
goal_list_purity(GoalList, Purity),
- add_goal_info_purity_feature(CombinedGoalInfo0,
- Purity, CombinedGoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, Detism, Purity,
+ CombinedGoalInfo),
simplify_info_set_requantify(Info3, Info4),
Goal = conj(GoalList),
@@ -2023,7 +2021,7 @@
% The test can't bind any variables, so the
% InstMapDelta should be empty.
instmap_delta_init_reachable(InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, semidet, ExtraGoalInfo).
+ goal_info_init(NonLocals, InstMapDelta, semidet, pure, ExtraGoalInfo).
%-----------------------------------------------------------------------------%
Index: compiler/table_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.43
diff -u -u -r1.43 table_gen.m
--- compiler/table_gen.m 14 Jan 2003 16:42:29 -0000 1.43
+++ compiler/table_gen.m 26 Feb 2003 01:10:53 -0000
@@ -564,6 +564,11 @@
pred_info_procedures(PredInfo1, ProcTable1),
map__det_update(ProcTable1, ProcId, ProcInfo, ProcTable),
pred_info_set_procedures(PredInfo1, ProcTable, PredInfo2),
+
+ %
+ % The transformation doesn't pay attention to the purity
+ % of compound goals, so recompute the purity here.
+ %
repuritycheck_proc(ModuleInfo2, proc(PredId, ProcId), PredInfo2,
PredInfo),
module_info_preds(ModuleInfo2, PredTable1),
@@ -708,7 +713,7 @@
instmap_delta_restrict(RestoreAnsInstMapDelta0,
RestoreAnsNonLocals, RestoreAnsInstMapDelta),
goal_info_init(RestoreAnsNonLocals, RestoreAnsInstMapDelta,
- det, Context, RestoreAnsGoalInfo0),
+ det, pure, Context, RestoreAnsGoalInfo0),
goal_info_add_feature(RestoreAnsGoalInfo0, hide_debug_event,
RestoreAnsGoalInfo),
RestoreAnsGoal = RestoreAnsGoalEx - RestoreAnsGoalInfo
@@ -744,7 +749,7 @@
instmap_delta_restrict(CallSaveAnsInstMapDelta0,
CallSaveAnsNonLocals, CallSaveAnsInstMapDelta),
goal_info_init(CallSaveAnsNonLocals, CallSaveAnsInstMapDelta, det,
- Context, CallSaveAnsGoalInfo0),
+ pure, Context, CallSaveAnsGoalInfo0),
goal_info_add_feature(CallSaveAnsGoalInfo0, hide_debug_event,
CallSaveAnsGoalInfo),
CallSaveAnsGoal = CallSaveAnsGoalEx - CallSaveAnsGoalInfo,
@@ -756,8 +761,8 @@
set__insert(OrigNonLocals, TableVar, GenIfNecNonLocals),
instmap_delta_restrict(GenIfNecInstMapDelta0, GenIfNecNonLocals,
GenIfNecInstMapDelta),
- goal_info_init(GenIfNecNonLocals, GenIfNecInstMapDelta, det, Context,
- GenIfNecGoalInfo0),
+ goal_info_init(GenIfNecNonLocals, GenIfNecInstMapDelta, det, pure,
+ Context, GenIfNecGoalInfo0),
goal_info_add_feature(GenIfNecGoalInfo0, hide_debug_event,
GenIfNecGoalInfo),
GenIfNecGoal = GenIfNecGoalEx - GenIfNecGoalInfo,
@@ -770,7 +775,7 @@
instmap_delta_restrict(CheckAndGenAnsInstMapDelta0,
CheckAndGenAnsNonLocals, CheckAndGenAnsInstMapDelta),
goal_info_init(CheckAndGenAnsNonLocals, CheckAndGenAnsInstMapDelta,
- det, Context, CheckAndGenAnsGoalInfo0),
+ det, pure, Context, CheckAndGenAnsGoalInfo0),
goal_info_add_feature(CheckAndGenAnsGoalInfo0, hide_debug_event,
CheckAndGenAnsGoalInfo),
CheckAndGenAnsGoal = CheckAndGenAnsGoalEx - CheckAndGenAnsGoalInfo,
@@ -781,8 +786,8 @@
BodyInstMapDelta0),
instmap_delta_restrict(BodyInstMapDelta0, OrigNonLocals,
BodyInstMapDelta),
- goal_info_init(OrigNonLocals, BodyInstMapDelta, det, Context,
- BodyGoalInfo0),
+ goal_info_init(OrigNonLocals, BodyInstMapDelta, det, pure,
+ Context, BodyGoalInfo0),
goal_info_add_feature(BodyGoalInfo0, hide_debug_event, BodyGoalInfo),
Goal = BodyGoalEx - BodyGoalInfo.
@@ -861,8 +866,8 @@
NoLoopGenInstMapDelta0),
instmap_delta_restrict(NoLoopGenInstMapDelta0, GenAnsNonLocals,
NoLoopGenInstMapDelta),
- goal_info_init(GenAnsNonLocals, NoLoopGenInstMapDelta, det, Context,
- NoLoopGenGoalInfo0),
+ goal_info_init(GenAnsNonLocals, NoLoopGenInstMapDelta, det, pure,
+ Context, NoLoopGenGoalInfo0),
goal_info_add_feature(NoLoopGenGoalInfo0, hide_debug_event,
NoLoopGenGoalInfo),
NoLoopGenAnsGoal = NoLoopGenAnsGoalEx - NoLoopGenGoalInfo,
@@ -873,8 +878,8 @@
NoLoopGenAnsGoal], GenAnsInstMapDelta0),
instmap_delta_restrict(GenAnsInstMapDelta0, GenAnsNonLocals,
GenAnsInstMapDelta),
- goal_info_init(GenAnsNonLocals, GenAnsInstMapDelta, det, Context,
- GenAnsGoalInfo0),
+ goal_info_init(GenAnsNonLocals, GenAnsInstMapDelta, det, pure,
+ Context, GenAnsGoalInfo0),
goal_info_add_feature(GenAnsGoalInfo0, hide_debug_event,
GenAnsGoalInfo),
GenAnsGoal = GenAnsGoalEx - GenAnsGoalInfo,
@@ -885,14 +890,14 @@
ITEInstMapDelta0),
instmap_delta_restrict(ITEInstMapDelta0, GenAnsNonLocals,
ITEInstMapDelta),
- goal_info_init(GenAnsNonLocals, ITEInstMapDelta, det, Context,
- ITEGoalInfo0),
+ goal_info_init(GenAnsNonLocals, ITEInstMapDelta, det, pure,
+ Context, ITEGoalInfo0),
goal_info_add_feature(ITEGoalInfo0, hide_debug_event, ITEGoalInfo),
ITEGoal = ITEGoalEx - ITEGoalInfo,
GoalEx = conj([LookUpGoal, ITEGoal]),
- goal_info_init(OrigNonLocals, OrigInstMapDelta, det, Context,
- GoalInfo0),
+ goal_info_init(OrigNonLocals, OrigInstMapDelta, det, pure,
+ Context, GoalInfo0),
goal_info_add_feature(GoalInfo0, hide_debug_event, GoalInfo),
Goal = GoalEx - GoalInfo,
generate_gen_proc_table_info(TableInfo, Steps, InputVars, OutputVars,
@@ -975,7 +980,7 @@
instmap_delta_restrict(NoLoopGenInstMapDelta0, GenAnsNonLocals,
NoLoopGenInstMapDelta),
goal_info_init(GenAnsNonLocals, NoLoopGenInstMapDelta, semidet,
- Context, NoLoopGenGoalInfo0),
+ pure, Context, NoLoopGenGoalInfo0),
goal_info_add_feature(NoLoopGenGoalInfo0, hide_debug_event,
NoLoopGenGoalInfo),
NoLoopGenAnsGoal = NoLoopGenAnsGoalEx - NoLoopGenGoalInfo,
@@ -987,7 +992,7 @@
instmap_delta_restrict(GenTrueAnsInstMapDelta0,
GenAnsNonLocals, GenTrueAnsInstMapDelta),
goal_info_init(GenAnsNonLocals, GenTrueAnsInstMapDelta,
- semidet, Context, GenTrueAnsGoalInfo0),
+ semidet, pure, Context, GenTrueAnsGoalInfo0),
goal_info_add_feature(GenTrueAnsGoalInfo0, hide_debug_event,
GenTrueAnsGoalInfo),
GenTrueAnsGoal = GenTrueAnsGoalEx - GenTrueAnsGoalInfo
@@ -1012,7 +1017,7 @@
instmap_delta_restrict(GenTrueAnsInstMapDelta0,
GenAnsNonLocals, GenTrueAnsInstMapDelta),
goal_info_init(GenAnsNonLocals, GenTrueAnsInstMapDelta,
- semidet, Context, GenTrueAnsGoalInfo0),
+ semidet, pure, Context, GenTrueAnsGoalInfo0),
goal_info_add_feature(GenTrueAnsGoalInfo0, hide_debug_event,
GenTrueAnsGoalInfo),
GenTrueAnsGoal = GenTrueAnsGoalEx - GenTrueAnsGoalInfo
@@ -1044,7 +1049,7 @@
instmap_delta_restrict(RestInstMapDelta0, RestNonLocals,
RestInstMapDelta),
goal_info_init(RestNonLocals, RestInstMapDelta, semidet,
- Context, RestAnsGoalInfo0),
+ pure, Context, RestAnsGoalInfo0),
goal_info_add_feature(RestAnsGoalInfo0, hide_debug_event,
RestAnsGoalInfo),
RestoreAnsGoal = RestAnsGoalEx - RestAnsGoalInfo
@@ -1056,7 +1061,7 @@
GenAnsGoalInstMapDelta0),
instmap_delta_restrict(GenAnsGoalInstMapDelta0, GenAnsNonLocals,
GenAnsGoalInstMapDelta),
- goal_info_init(GenAnsNonLocals, GenAnsGoalInstMapDelta, semidet,
+ goal_info_init(GenAnsNonLocals, GenAnsGoalInstMapDelta, semidet, pure,
Context, GenAnsGoalInfo0),
goal_info_add_feature(GenAnsGoalInfo0, hide_debug_event,
GenAnsGoalInfo),
@@ -1068,14 +1073,14 @@
ITEInstMapDelta0),
instmap_delta_restrict(ITEInstMapDelta0, GenAnsNonLocals,
ITEInstMapDelta),
- goal_info_init(GenAnsNonLocals, ITEInstMapDelta, semidet,
+ goal_info_init(GenAnsNonLocals, ITEInstMapDelta, semidet, pure,
Context, ITEGoalInfo0),
goal_info_add_feature(ITEGoalInfo0, hide_debug_event, ITEGoalInfo),
ITEGoal = ITEGoalEx - ITEGoalInfo,
GoalEx = conj([LookUpGoal, ITEGoal]),
- goal_info_init(OrigNonLocals, OrigInstMapDelta, semidet, Context,
- GoalInfo0),
+ goal_info_init(OrigNonLocals, OrigInstMapDelta, semidet, pure,
+ Context, GoalInfo0),
goal_info_add_feature(GoalInfo0, hide_debug_event, GoalInfo),
Goal = GoalEx - GoalInfo,
generate_gen_proc_table_info(TableInfo, Steps, InputVars, OutputVars,
@@ -1158,7 +1163,7 @@
instmap_delta_restrict(GenAnsGoalPart1IMD0, GenAnsGoalPart1NonLocals,
GenAnsGoalPart1IMD),
goal_info_init(GenAnsGoalPart1NonLocals, GenAnsGoalPart1IMD, nondet,
- Context, GenAnsGoalPart1GoalInfo0),
+ pure, Context, GenAnsGoalPart1GoalInfo0),
goal_info_add_feature(GenAnsGoalPart1GoalInfo0, hide_debug_event,
GenAnsGoalPart1GoalInfo),
GenAnsGoalPart1 = GenAnsGoalPart1Ex - GenAnsGoalPart1GoalInfo,
@@ -1188,8 +1193,8 @@
),
GoalEx = conj([LookUpGoal, ITE2Goal]),
- goal_info_init(OrigNonLocals, OrigInstMapDelta, nondet, Context,
- GoalInfo0),
+ goal_info_init(OrigNonLocals, OrigInstMapDelta, nondet, pure,
+ Context, GoalInfo0),
goal_info_add_feature(GoalInfo0, hide_debug_event, GoalInfo),
Goal = GoalEx - GoalInfo,
generate_gen_proc_table_info(TableInfo, Steps, InputVars, OutputVars,
@@ -1257,7 +1262,7 @@
set__singleton_set(NonLocals0, TableVar),
set__insert_list(NonLocals0, Vars, NonLocals),
instmap_delta_from_assoc_list([], InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, det, Context, GoalInfo0),
+ goal_info_init(NonLocals, InstMapDelta, det, pure, Context, GoalInfo0),
goal_info_get_features(GoalInfo0, Features0),
set__insert(Features0, call_table_gen, Features),
goal_info_set_features(GoalInfo0, Features, GoalInfo),
@@ -1294,7 +1299,7 @@
set__insert_list(NonLocals0, Vars, NonLocals),
create_instmap_delta(Goals, InstMapDelta0),
instmap_delta_restrict(InstMapDelta0, NonLocals, InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, det, Context, GoalInfo0),
+ goal_info_init(NonLocals, InstMapDelta, det, pure, Context, GoalInfo0),
goal_info_get_features(GoalInfo0, Features0),
set__insert(Features0, call_table_gen, Features),
goal_info_set_features(GoalInfo0, Features, GoalInfo),
@@ -1366,8 +1371,8 @@
set__insert_list(NonLocals0, [TableVar, ArgVar],
NonLocals),
instmap_delta_from_assoc_list([], InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, det, Context,
- GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, det, pure,
+ Context, GoalInfo),
Goal = conj([RangeUnifyGoal, LookupGoal]) - GoalInfo,
Step = table_trie_step_enum(EnumRange),
TableInfo = TableInfo0
@@ -1454,7 +1459,7 @@
create_instmap_delta([BlockSizeVarUnifyGoal, CreateAnsBlockGoal
| SaveGoals], InstMapDelta0),
instmap_delta_restrict(InstMapDelta0, NonLocals, InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, det, Context,
+ goal_info_init(NonLocals, InstMapDelta, det, pure, Context,
GoalInfo),
Goal = GoalEx - GoalInfo
;
@@ -1517,7 +1522,8 @@
set__insert_list(NonLocals0, OutputVars, NonLocals),
create_instmap_delta(Goals, InstMapDelta0),
instmap_delta_restrict(InstMapDelta0, NonLocals, InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, semidet, Context, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, semidet,
+ pure, Context, GoalInfo),
Goal = GoalEx - GoalInfo.
:- pred generate_save_goals(assoc_list(prog_var, int)::in, prog_var::in,
@@ -1611,7 +1617,7 @@
set__insert_list(NonLocals0, OutputVars, NonLocals),
create_instmap_delta(RestoreGoals, InstMapDelta0),
instmap_delta_restrict(InstMapDelta0, NonLocals, InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, det, Context, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, det, pure, Context, GoalInfo),
Goal = GoalEx - GoalInfo.
:- pred generate_restore_all_goal(determinism::in,
@@ -1647,7 +1653,8 @@
create_instmap_delta([ReturnAnsBlocksGoal | RestoreGoals],
InstMapDelta0),
instmap_delta_restrict(InstMapDelta0, NonLocals, InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, nondet, Context, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, nondet,
+ pure, Context, GoalInfo),
Goal = GoalEx - GoalInfo.
:- pred generate_restore_goals(assoc_list(prog_var, int)::in, prog_var::in,
@@ -1720,7 +1727,8 @@
create_instmap_delta([ReturnAnsBlocksGoal | RestoreGoals],
InstMapDelta0),
instmap_delta_restrict(InstMapDelta0, NonLocals, InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, nondet, Context, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, nondet,
+ pure, Context, GoalInfo),
Goal = GoalEx - GoalInfo.
%-----------------------------------------------------------------------------%
@@ -1754,7 +1762,8 @@
create_instmap_delta([MessageConsGoal, CallGoal],
InstMapDelta0),
instmap_delta_restrict(InstMapDelta0, NonLocals, InstMapDelta),
- goal_info_init(NonLocals, InstMapDelta, erroneous, Context, GoalInfo),
+ goal_info_init(NonLocals, InstMapDelta, erroneous, pure,
+ Context, GoalInfo),
Goal = GoalEx - GoalInfo.
%-----------------------------------------------------------------------------%
@@ -1786,7 +1795,7 @@
goal_info_get_nonlocals(GoalInfo, NonLocals),
goal_info_get_context(GoalInfo, Context),
instmap_delta_init_unreachable(UnreachInstMapDelta),
- goal_info_init(NonLocals, UnreachInstMapDelta, failure, Context,
+ goal_info_init(NonLocals, UnreachInstMapDelta, failure, pure, Context,
ConjGoalInfo),
fail_goal(FailGoal),
GoalAndThenFail = conj([Goal, FailGoal]) - ConjGoalInfo.
Index: compiler/unify_proc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unify_proc.m,v
retrieving revision 1.115
diff -u -u -r1.115 unify_proc.m
--- compiler/unify_proc.m 22 Feb 2003 13:18:29 -0000 1.115
+++ compiler/unify_proc.m 25 Feb 2003 13:19:41 -0000
@@ -1571,7 +1571,8 @@
GoalExpr = call(PredId, ProcId, ArgVars, not_builtin, no,
PredName),
set__list_to_set(ArgVars, NonLocals),
- goal_info_init(NonLocals, InstmapDelta, Detism, GoalInfo0),
+ goal_info_init(NonLocals, InstmapDelta,
+ Detism, pure, GoalInfo0),
goal_info_set_context(GoalInfo0, Context, GoalInfo),
Goal = GoalExpr - GoalInfo
;
Index: tests/hard_coded/purity/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/purity/Mercury.options,v
retrieving revision 1.1
diff -u -u -r1.1 Mercury.options
--- tests/hard_coded/purity/Mercury.options 17 Aug 2002 13:52:15 -0000 1.1
+++ tests/hard_coded/purity/Mercury.options 27 Feb 2003 13:54:46 -0000
@@ -0,0 +1 @@
+MCFLAGS-purity_opt = --local-constraint-propagation --no-fully-strict
Index: tests/hard_coded/purity/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/purity/Mmakefile,v
retrieving revision 1.4
diff -u -u -r1.4 Mmakefile
--- tests/hard_coded/purity/Mmakefile 27 Jan 2003 09:21:01 -0000 1.4
+++ tests/hard_coded/purity/Mmakefile 26 Feb 2003 13:48:55 -0000
@@ -5,11 +5,12 @@
#-----------------------------------------------------------------------------#
PURITY_PROGS= \
- purity \
impure_func_t1 \
impure_func_t5_fixed2 \
impure_func_t6 \
- impure_pred_t1_fixed3
+ impure_pred_t1_fixed3 \
+ purity \
+ purity_opt
# We currently don't do any testing in grade java on this directory.
ifneq "$(findstring java,$(GRADE))" ""
Index: tests/hard_coded/purity/purity_opt.exp
===================================================================
RCS file: tests/hard_coded/purity/purity_opt.exp
diff -N tests/hard_coded/purity/purity_opt.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/purity/purity_opt.exp 27 Feb 2003 13:58:54 -0000
@@ -0,0 +1 @@
+4
Index: tests/hard_coded/purity/purity_opt.m
===================================================================
RCS file: tests/hard_coded/purity/purity_opt.m
diff -N tests/hard_coded/purity/purity_opt.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/purity/purity_opt.m 27 Feb 2003 13:58:48 -0000
@@ -0,0 +1,65 @@
+% Test for bugs in the handling of purity by the optimization passes.
+:- module purity_opt.
+:- interface.
+:- import_module io.
+
+:- impure pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module int, require, std_util.
+
+main -->
+ ( { impure test1(1), impure test1(2), impure test1(3) } ->
+ { semipure get(C1) },
+ io__write_int(C1),
+ io__nl
+ ;
+ { error("test1 failed") }
+ ).
+
+:- impure pred test1(int::in) is semidet.
+:- pragma no_inline(test1/1).
+
+test1(X) :-
+ (
+ impure incr(_),
+ fail
+ ;
+ true
+ ),
+ ( X > 1 ->
+ Z = X - 1
+ ;
+ Z = 3
+ ),
+ Z < 4.
+
+:- pragma foreign_decl("C",
+"
+ int counter;
+").
+
+:- pragma foreign_code("C",
+"
+ int counter = 1;
+").
+
+:- pragma foreign_code("C#", "static int counter = 1;").
+
+:- impure pred incr(int::out) is det.
+
+:- pragma foreign_proc("C", incr(Val::out), [will_not_call_mercury],
+ "counter++; Val = counter;").
+:- pragma foreign_proc("C#", incr(Val::out), [will_not_call_mercury],
+ "counter++; Val = counter;").
+
+:- semipure pred get(int::out) is det.
+
+:- pragma foreign_proc("C", get(Val::out),
+ [will_not_call_mercury, promise_semipure],
+ "Val = counter").
+:- pragma foreign_proc("C#", get(Val::out),
+ [will_not_call_mercury, promise_semipure],
+ "Val = counter;").
+
--------------------------------------------------------------------------
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