for review: bug fixes for inter-module optimization
Simon Taylor
stayl at cs.mu.OZ.AU
Thu Feb 19 09:45:47 AEDT 1998
Hi,
Tom, could you please review this.
Simon.
Estimated hours taken: 1.5
Bug fixes for inter-module optimization.
compiler/Mmakefile
Use the `.int' files in $(LIBRARY_DIR) rather than the installed
`.int' files when creating `.opt' files for the compiler.
compiler/intermod.m
Handle higher-order function calls properly. This caused
mmc --make-optimization-interface --enable-termination \
tests/hard_coded/agg.m to fail.
Make sure types used by abstract exported types are made
exported when compiling to C. This ensures that the
base_type_infos are exported, avoiding link errors.
tests/general/intermod_type.m
tests/general/intermod_type2.m
tests/general/intermod_type.exp
Regression test for abstract exported types.
Index: compiler/Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/Mmakefile,v
retrieving revision 1.7
diff -u -r1.7 Mmakefile
--- Mmakefile 1998/01/09 07:35:17 1.7
+++ Mmakefile 1998/02/18 11:22:34
@@ -21,6 +21,11 @@
MCD = MERCURY_INT_DIR=. $(MC) --generate-dependencies
MCI = MERCURY_INT_DIR=$(LIBRARY_DIR) $(MC) --make-interface
+MCSI = MERCURY_INT_DIR=$(LIBRARY_DIR) $(MC) --make-short-interface
+MCOI = MERCURY_INT_DIR=$(LIBRARY_DIR) $(MC) \
+ --make-optimization-interface
+MCTOI = MERCURY_INT_DIR=$(LIBRARY_DIR) $(MC) \
+ --make-transitive-optimization-interface
MCG = MERCURY_C_INCL_DIR=$(RUNTIME_DIR) \
MERCURY_INT_DIR=$(LIBRARY_DIR) $(MC) --compile-to-c
MCS = MERCURY_C_INCL_DIR=$(RUNTIME_DIR) \
Index: compiler/intermod.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/intermod.m,v
retrieving revision 1.44
diff -u -r1.44 intermod.m
--- intermod.m 1998/02/12 01:17:21 1.44
+++ intermod.m 1998/02/18 13:57:33
@@ -522,6 +522,19 @@
intermod_info_get_tvarset(TVarSet),
intermod_info_get_var_types(VarTypes),
(
+ % Is it a higher-order function call?
+ % (higher-order predicate calls are transformed into
+ % higher_order_call goals by make_hlds.m).
+ { Functor0 = cons(unqualified(ApplyName), _) },
+ { ApplyName = "apply"
+ ; ApplyName = ""
+ },
+ { list__length(Vars, ApplyArity) },
+ { ApplyArity >= 1 }
+ ->
+ { Functor = Functor0 },
+ { DoWrite = yes }
+ ;
%
% Is it a function call?
%
@@ -1146,7 +1159,8 @@
globals__lookup_int_option(Globals, intermod_inline_simple_threshold,
Threshold),
intermod__gather_preds(PredIds, yes, Threshold, Info0, Info1),
- do_adjust_pred_import_status(Info1, Module0, Module).
+ intermod__gather_abstract_exported_types(Info1, Info),
+ do_adjust_pred_import_status(Info, Module0, Module).
:- pred do_adjust_pred_import_status(intermod_info::in,
module_info::in, module_info::out) is det.
Index: tests/general/Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/tests/general/Mmakefile,v
retrieving revision 1.4
diff -u -r1.4 Mmakefile
--- Mmakefile 1998/02/11 09:23:08 1.4
+++ Mmakefile 1998/02/17 06:18:59
@@ -40,6 +40,7 @@
float_test \
frameopt_mkframe_bug \
higher_order \
+ intermod_type \
liveness \
liveness2 \
mode_inf_bug \
@@ -63,6 +64,8 @@
# mode_inf and mode_inf_bug need to be compiled with `--infer-all'.
MCFLAGS-mode_inf = --infer-all
MCFLAGS-mode_inf_bug = --infer-all
+MCFLAGS-intermod_type = --intermodule-optimization
+MCFLAGS-intermod_type2 = --intermodule-optimization
# In grade `none' with options `-O1 --opt-space' on kryten
# (a sparc-sun-solaris2.5 system), string_test needs to be linked
tests/general/intermod_type.m
==============================================================================
% Regression test for a bug in intermodule optimization - base_type_infos
% for types used by abstract exported predicates in `.opt' files were
% not being exported, causing a link error.
%
:- module intermod_type.
%------------------------------------------------------------------------------%
:- interface.
:- import_module intermod_type2.
:- import_module int, io, list, std_util.
:- pred main(io__state::di, io__state::uo) is det.
:- type dungeon.
:- type player == who.
:- type level
---> lev(
int, int, % width, height (== 80 * 22)
list(who),
win
).
:- type pos
---> pos(int, int).
:- type who.
:- type runq == list(pair(int, list(who))).
%------------------------------------------------------------------------------%
:- type rnd == int.
%------------------------------------------------------------------------------%
%------------------------------------------------------------------------------%
:- implementation.
:- import_module store.
main -->
io__write_string("OK\n").
%------------------------------------------------------------------------------%
:- type who == int.
:- type dungeon
---> dun(
win, % Root window, for messages
win, % main window
win, % message window
player,
list(level), % levels above me
level, % current level
list(level), % levels below me
rnd,
int, % current cycle
runq
).
%------------------------------------------------------------------------------%
tests/general/intermod_type2.m
==============================================================================
:- module intermod_type2.
:- interface.
:- type win.
:- type wopt
---> border
; title(string)
.
:- implementation.
%------------------------------------------------------------------------------%
:- import_module array, char, int, list, require, std_util, store, string.
:- type curse == store(some_store_type).
:- type win == mutvar(window, some_store_type).
:- type window
---> win(
win, % parent
int, % width
int, % height
list(wopt),
array(char), % contents
list(child), % visible
list(child) % hidden
).
:- type child
---> child(
int, % x
int, % y
win
).
:- type cursor
---> cursor(int, int).
%------------------------------------------------------------------------------%
tests/general/intermod_type.exp
==============================================================================
OK
More information about the developers
mailing list