[m-rev.] diff: fix problem with optimization of builtin.false/0

Julien Fischer juliensf at cs.mu.OZ.AU
Fri Feb 17 03:37:50 AEDT 2006


Estimated hours taken: 2
Branches: main

Fix a problem introduced by my recent changes to simplify.m that broke the
nightly builds on those hosts that use `--intermodule-optimization'.  When
compiling with `--intermodule-optimization --no-fully-strict' simplify now
realises that it can replace calls to `builtin.false/0' with `fail'.  In the
process of doing so it was emitting warning about `false' never succeeding.

compiler/simplify.m:
	Don't emit a warning when replacing calls to builtin.false/0 with
	fail.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/builtin_false.m:
	Test case for the above.

Julien.

Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.163
diff -u -r1.163 simplify.m
--- compiler/simplify.m	16 Feb 2006 05:48:30 -0000	1.163
+++ compiler/simplify.m	16 Feb 2006 16:19:25 -0000
@@ -417,15 +417,19 @@
         ; Goal0CannotLoopOrThrow = yes
         )
     ->
-        % warn about this, unless the goal was an explicit
-        % `fail', or some goal containing `fail'.
-
+        % Warn about this, unless the goal was an explicit `fail', some goal
+        % containing `fail' or a call to `builtin.false/0'.
+        %
         goal_info_get_context(GoalInfo0, Context),
         (
             simplify_do_warn(!.Info),
             \+ (
-                goal_contains_goal(Goal0, SubGoal),
-                SubGoal = disj([]) - _
+                (
+                    goal_contains_goal(Goal0, SubGoal),
+                    SubGoal = disj([]) - _
+                ;
+                    goal_is_call_to_builtin_false(Goal0)
+                )
             )
         ->
             Msg = goal_cannot_succeed,
@@ -559,6 +563,12 @@
     ;
         GoalInfo = GoalInfo0
     ).
+
+:- pred goal_is_call_to_builtin_false(hlds_goal::in) is semidet.
+
+goal_is_call_to_builtin_false(Goal - _) :-
+    Goal = call(_, _, _, _, _, SymName),
+    SymName = qualified(mercury_public_builtin_module, "false").

 %-----------------------------------------------------------------------------%

Index: tests/valid/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mercury.options,v
retrieving revision 1.27
diff -u -r1.27 Mercury.options
--- tests/valid/Mercury.options	13 Feb 2006 06:30:07 -0000	1.27
+++ tests/valid/Mercury.options	16 Feb 2006 16:28:10 -0000
@@ -31,6 +31,7 @@
 MCFLAGS-aditi_update		= --aditi
 MCFLAGS-base_relation2		= --aditi
 MCFLAGS-base_relation		= --aditi
+MCFLAGS-builtin_false		= --intermodule-optimization
 MCFLAGS-compl_unify_bug		= -O3
 MCFLAGS-constraint_prop_bug	= -O0 --common-struct --local-constraint-propagation
 MCFLAGS-context_anc		= --aditi
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.164
diff -u -r1.164 Mmakefile
--- tests/valid/Mmakefile	10 Feb 2006 05:00:05 -0000	1.164
+++ tests/valid/Mmakefile	16 Feb 2006 16:25:12 -0000
@@ -68,6 +68,7 @@
 	any_inst_merge \
 	any_matches_bound \
 	big_foreign_type \
+	builtin_false \
 	common_struct_bug \
 	complicated_unify \
 	compl_unify_bug \
Index: tests/valid/builtin_false.m
===================================================================
RCS file: tests/valid/builtin_false.m
diff -N tests/valid/builtin_false.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/builtin_false.m	16 Feb 2006 16:24:54 -0000
@@ -0,0 +1,17 @@
+% rotd-02-17 emitted a warning about the call to false never succeeding if
+% compiling with --intermodule-optimization and --no-fully-strict.
+%
+:- module builtin_false.
+
+:- interface.
+
+:- pred foo(int::in, int::out) is semidet.
+
+:- implementation.
+
+foo(X, Y) :-
+	( X = 3 ->
+		Y = 4
+	;
+		false
+	).

--------------------------------------------------------------------------
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