[m-rev.] diff: fix another bug in smart recompilation
Simon Taylor
stayl at cs.mu.OZ.AU
Mon Nov 5 20:42:23 AEDT 2001
On 05-Nov-2001, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
>
>
> Estimated hours taken: 0.5
>
> Fix a bug in smart recompilation which caused some interface
> files to be updated even if the source file was only `touch'ed.
>
> compiler/recompilation_version.m:
> Ignore the determinism on a predicate declaration
> when checking whether it has changed. recompilation_version.m
> splits combined predicate and mode declarations before checking
> whether the predicate's declarations have changed. The problem
> only occurred if a predicate with a separate mode declaration
> also had a determinism annotation on the `:- pred' declaration.
>
> compiler/mercury_to_mercury.m:
> Remove the `is det' from the `:- pred' declaration
> for mercury_output_pragma_unused_args.
>
> tests/recompilation/TESTS:
> tests/recompilation/unchanged_pred_nr*:
> Test case.
Estimated hours taken: 0.5
Fix a bug in my last change.
compiler/recompilation_version.m:
The log message for my last change said:
"Ignore the determinism on a predicate declaration
when checking whether it has changed. recompilation_version.m
splits combined predicate and mode declarations before checking
whether the predicate's declarations have changed. The problem
only occurred if a predicate with a separate mode declaration
also had a determinism annotation on the `:- pred' declaration."
For function declarations, a determinism declaration with no
modes means use the default modes. These aren't split out into
a separate declaration, so the determinism on a function type
declaration can't be ignored here.
tests/recompilation/TESTS:
tests/recompilation/changed_func_r*:
Test case.
Index: compiler/recompilation_version.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/recompilation_version.m,v
retrieving revision 1.7
diff -u -u -r1.7 recompilation_version.m
--- compiler/recompilation_version.m 4 Nov 2001 17:22:59 -0000 1.7
+++ compiler/recompilation_version.m 5 Nov 2001 09:38:53 -0000
@@ -564,16 +564,29 @@
( Item2 = nothing(A) -> yes ; no ).
item_is_unchanged(Item1, Item2) = Result :-
- % Ignore the determinism -- the modes and determinism should
- % have been split into a separate declaration. This case
- % can only happen if this was not a combined predicate and
- % mode declaration. XXX We should warn about this somewhere.
Item1 = pred_or_func(TVarSet1, _, ExistQVars1, PredOrFunc,
- Name, TypesAndModes1, _Det1, Cond, Purity, Constraints1),
+ Name, TypesAndModes1, Det1, Cond, Purity, Constraints1),
(
Item2 = pred_or_func(TVarSet2, _, ExistQVars2,
- PredOrFunc, Name, TypesAndModes2, _Det2, Cond, Purity,
+ PredOrFunc, Name, TypesAndModes2, Det2, Cond, Purity,
Constraints2),
+
+ % For predicates, ignore the determinism -- the modes and
+ % determinism should have been split into a separate
+ % declaration. This case can only happen if this was
+ % not a combined predicate and mode declaration
+ % (XXX We should warn about this somewhere).
+ % For functions a determinism declaration but no modes
+ % implies the default modes. The default modes are
+ % added later by make_hlds.m, so they won't have been
+ % split into a separate declaration here.
+ (
+ PredOrFunc = function,
+ Det1 = Det2
+ ;
+ PredOrFunc = predicate
+ ),
+
pred_or_func_type_is_unchanged(TVarSet1, ExistQVars1,
TypesAndModes1, Constraints1, TVarSet2,
ExistQVars2, TypesAndModes2, Constraints2)
Index: tests/recompilation/TESTS
===================================================================
RCS file: /home/mercury1/repository/tests/recompilation/TESTS,v
retrieving revision 1.7
diff -u -u -r1.7 TESTS
--- tests/recompilation/TESTS 4 Nov 2001 17:23:17 -0000 1.7
+++ tests/recompilation/TESTS 5 Nov 2001 09:05:51 -0000
@@ -9,6 +9,7 @@
add_instance_2_r \
add_type_nr \
change_class_r \
+ change_func_r \
change_instance_r \
change_mode_r \
change_type_nr \
Index: tests/recompilation/change_func_r.err_exp.2
===================================================================
RCS file: tests/recompilation/change_func_r.err_exp.2
diff -N tests/recompilation/change_func_r.err_exp.2
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation/change_func_r.err_exp.2 5 Nov 2001 09:10:06 -0000
@@ -0,0 +1,2 @@
+Recompiling module `change_func_r':
+ function `change_func_r_2:changed_func/1' was modified.
Index: tests/recompilation/change_func_r.exp.1
===================================================================
RCS file: tests/recompilation/change_func_r.exp.1
diff -N tests/recompilation/change_func_r.exp.1
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation/change_func_r.exp.1 5 Nov 2001 09:04:30 -0000
@@ -0,0 +1 @@
+OK
Index: tests/recompilation/change_func_r.exp.2
===================================================================
RCS file: tests/recompilation/change_func_r.exp.2
diff -N tests/recompilation/change_func_r.exp.2
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation/change_func_r.exp.2 5 Nov 2001 09:04:30 -0000
@@ -0,0 +1 @@
+OK
Index: tests/recompilation/change_func_r.m.1
===================================================================
RCS file: tests/recompilation/change_func_r.m.1
diff -N tests/recompilation/change_func_r.m.1
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation/change_func_r.m.1 5 Nov 2001 09:09:52 -0000
@@ -0,0 +1,19 @@
+:- module change_func_r.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module change_func_r_2, std_util.
+
+main -->
+ ( { semidet_succeed, Str = changed_func("OK\n") } ->
+ io__write_string(Str)
+ ;
+ io__write_string("failed\n")
+ ).
+
Index: tests/recompilation/change_func_r_2.err_exp.2
===================================================================
RCS file: tests/recompilation/change_func_r_2.err_exp.2
diff -N tests/recompilation/change_func_r_2.err_exp.2
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation/change_func_r_2.err_exp.2 5 Nov 2001 09:10:06 -0000
@@ -0,0 +1,2 @@
+Recompiling module `change_func_r_2':
+ file `change_func_r_2.m' has changed.
Index: tests/recompilation/change_func_r_2.m.1
===================================================================
RCS file: tests/recompilation/change_func_r_2.m.1
diff -N tests/recompilation/change_func_r_2.m.1
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation/change_func_r_2.m.1 5 Nov 2001 09:07:57 -0000
@@ -0,0 +1,9 @@
+:- module change_func_r_2.
+
+:- interface.
+
+:- func changed_func(string) = string is det.
+
+:- implementation.
+
+changed_func(X) = X.
Index: tests/recompilation/change_func_r_2.m.2
===================================================================
RCS file: tests/recompilation/change_func_r_2.m.2
diff -N tests/recompilation/change_func_r_2.m.2
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/recompilation/change_func_r_2.m.2 5 Nov 2001 09:08:28 -0000
@@ -0,0 +1,12 @@
+:- module change_func_r_2.
+
+:- interface.
+
+:- func changed_func(string) = string is semidet.
+
+:- implementation.
+
+:- import_module std_util.
+
+changed_func(X) = X :-
+ semidet_succeed.
--------------------------------------------------------------------------
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