[m-rev.] for review: fix mantis bug #42
Peter Wang
novalazy at gmail.com
Wed Jun 11 16:55:10 AEST 2008
Pending bootcheck.
Estimated hours taken: 1
Branches: main
Fix Mantis bug #42. --optimize-constructor-last-call wouldn't work together
with --no-inline-builtins (or more commonly, --no-inlining).
We didn't generate a valid definition for `private_builtin.store_at_ref': the
procedure existed but had an empty body. With `--no-inlining-builtins' the
calls to `store_at_ref' introduced by the LCMC that would normally be replaced
by inline code would go to the out-of-line procedure, which did nothing.
compiler/add_pred.m:
Allow `add_builtin' to generate a body for `store_at_ref'.
(builtin_compound_eq/builtin_compound_lt may require the same
treatment for Erlang backend; I haven't tested.)
tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
tests/hard_coded/lco_no_inline.exp:
tests/hard_coded/lco_no_inline.m:
Add a test case.
Index: compiler/add_pred.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pred.m,v
retrieving revision 1.33
diff -u -r1.33 add_pred.m
--- compiler/add_pred.m 23 Nov 2007 07:34:53 -0000 1.33
+++ compiler/add_pred.m 11 Jun 2008 06:13:13 -0000
@@ -243,21 +243,15 @@
goal_info_set_nonlocals(NonLocals, GoalInfo0, GoalInfo),
(
Module = mercury_private_builtin_module,
- (
- Name = "store_at_ref",
- StubPrime = no
- ;
- ( Name = "builtin_compound_eq"
- ; Name = "builtin_compound_lt"
- ),
- StubPrime = yes
+ ( Name = "builtin_compound_eq"
+ ; Name = "builtin_compound_lt"
)
->
GoalExpr = conj(plain_conj, []),
ExtraVars = [],
ExtraTypes = [],
VarSet = VarSet0,
- Stub = StubPrime
+ Stub = yes
;
Module = mercury_private_builtin_module,
Name = "trace_get_io_state"
Index: tests/hard_coded/Mercury.options
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/Mercury.options,v
retrieving revision 1.34
diff -u -r1.34 Mercury.options
--- tests/hard_coded/Mercury.options 22 May 2008 04:11:29 -0000 1.34
+++ tests/hard_coded/Mercury.options 11 Jun 2008 06:23:27 -0000
@@ -37,6 +37,7 @@
MCFLAGS-intermod_type_qual2 = --intermodule-optimization
MCFLAGS-intermod_multimode = --intermodule-optimization
MCFLAGS-intermod_multimode_main = --intermodule-optimization
+MCFLAGS-lco_no_inline = --optimize-constructor-last-call --no-inline-builtins
MCFLAGS-sharing_comb = --ctgc --structure-sharing-widening 2
MCFLAGS-uncond_reuse = --ctgc
MCFLAGS-uncond_reuse_bad = --ctgc
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.353
diff -u -r1.353 Mmakefile
--- tests/hard_coded/Mmakefile 4 Jun 2008 03:10:20 -0000 1.353
+++ tests/hard_coded/Mmakefile 11 Jun 2008 06:29:02 -0000
@@ -136,6 +136,7 @@
intermod_type_qual \
intermod_unused_args \
join_list \
+ lco_no_inline \
list_series_int \
loop_inv_test \
loop_inv_test1 \
Index: tests/hard_coded/lco_no_inline.exp
===================================================================
RCS file: tests/hard_coded/lco_no_inline.exp
diff -N tests/hard_coded/lco_no_inline.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/lco_no_inline.exp 11 Jun 2008 06:24:02 -0000
@@ -0,0 +1 @@
+["one", "two", "two"]
Index: tests/hard_coded/lco_no_inline.m
===================================================================
RCS file: tests/hard_coded/lco_no_inline.m
diff -N tests/hard_coded/lco_no_inline.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/lco_no_inline.m 11 Jun 2008 06:29:49 -0000
@@ -0,0 +1,42 @@
+% Regression test. There was no out-of-line definition of
+% private_builtin.store_at_ref which is required for
+% --optimise-constructor-last-call and --no-inline-builtins to work together.
+
+%-----------------------------------------------------------------------------%
+
+:- module lco_no_inline.
+:- interface.
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module int.
+:- import_module list.
+:- import_module pair.
+
+%-----------------------------------------------------------------------------%
+
+main(!IO) :-
+ AL = ["one" - 1, "two" - 2],
+ to_list_2(AL, L),
+ io.write(L, !IO),
+ io.nl(!IO).
+
+:- pred to_list_2(list(pair(string, int))::in, list(string)::out) is det.
+
+to_list_2([], []).
+to_list_2([X - Int | Xs], Out) :-
+ ( Int =< 0 ->
+ to_list_2(Xs, Out)
+ ;
+ NewInt = Int - 1,
+ to_list_2([X - NewInt | Xs], Out0),
+ Out = [X | Out0]
+ ).
+
+%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
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