[m-rev.] for review: Modify the code generator to generate code for constructing terms in region.

Quan Phan Quan.Phan at cs.kuleuven.be
Tue Jul 17 15:11:23 AEST 2007


Hi,

Estimated hours taken: 20.
Branch: main.

Modify the code generator so that it recognizes construct_in_region and 
generates suitable code when RBMM is used. The main
changes are in unify_gen.m. incr_hp is also changed to receive one more
(maybe) argument for region.

The region runtime system will be posted in another email.

compiler/code_info.m:
compiler/var_locn.m:
        Change in accordance with the introduction of how_to_construct in
	unify_gen.m.

compiler/llds.m:
	Add one extra argument to incr_hp for the region to construct terms
	in.
	
compiler/dupelim.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/global_data.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_to_x86_64.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/reasign.m:
compiler/use_local_vars.m:
	Change to deal with the extra maybe region argument in incr_hp.
	
compiler/llds_out.m:
	Modify so that when RBMM is used it generates suitable call to 
	the region runtime for allocating terms in regions. The region
	runtime (in C code) will be posted in anothe email.

compiler/hlds_data.m:
	Fix a typo.

compiler/rbmm.interproc_region_lifetime.m:
	Change to comply with coding standard.
	
compiler/unify_gen.m:
	Make it aware of HowToConstruct. This is the starting point of the
	changes in the code generator so that it can generate code which
	constructs terms in regions.

Index: code_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.344
diff -u -u -r1.344 code_info.m
--- code_info.m	19 Jan 2007 07:04:08 -0000	1.344
+++ code_info.m	19 Jun 2007 03:00:17 -0000
@@ -3164,8 +3164,8 @@
     %   FieldAddrs, TypeMsg, MayUseAtomic, Where, Code, !CI).
     %
 :- pred assign_cell_to_var(prog_var::in, bool::in, tag::in,
-    list(maybe(rval))::in, maybe(term_size_value)::in, list(int)::in,
-    string::in, may_use_atomic_alloc::in, code_tree::out,
+    list(maybe(rval))::in, how_to_construct::in, maybe(term_size_value)::in,
+    list(int)::in, string::in, may_use_atomic_alloc::in, code_tree::out,
     code_info::in, code_info::out) is det.
 
 :- pred place_var(prog_var::in, lval::in, code_tree::out,
@@ -3303,14 +3303,15 @@
     ),
     set_var_locn_info(VarLocnInfo, !CI).
 
-assign_cell_to_var(Var, ReserveWordAtStart, Ptag, MaybeRvals, MaybeSize,
-        FieldAddrs, TypeMsg, MayUseAtomic, Code, !CI) :-
+assign_cell_to_var(Var, ReserveWordAtStart, Ptag, MaybeRvals, HowToConstruct,
+        MaybeSize, FieldAddrs, TypeMsg, MayUseAtomic, Code, !CI) :-
     get_var_locn_info(!.CI, VarLocnInfo0),
     get_static_cell_info(!.CI, StaticCellInfo0),
     get_module_info(!.CI, ModuleInfo),
     var_locn_assign_cell_to_var(ModuleInfo, Var, ReserveWordAtStart, Ptag,
-        MaybeRvals, MaybeSize, FieldAddrs, TypeMsg, MayUseAtomic, Code,
-        StaticCellInfo0, StaticCellInfo, VarLocnInfo0, VarLocnInfo),
+        MaybeRvals, HowToConstruct, MaybeSize, FieldAddrs, TypeMsg,
+        MayUseAtomic, Code, StaticCellInfo0, StaticCellInfo,
+        VarLocnInfo0, VarLocnInfo),
     set_static_cell_info(StaticCellInfo, !CI),
     set_var_locn_info(VarLocnInfo, !CI).
 
Index: dupelim.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dupelim.m,v
retrieving revision 1.89
diff -u -u -r1.89 dupelim.m
--- dupelim.m	6 Jan 2007 09:23:30 -0000	1.89
+++ dupelim.m	20 Jun 2007 06:41:40 -0000
@@ -41,7 +41,7 @@
 % identical.
 % 
 %-----------------------------------------------------------------------------%
-
+ 
 :- module ll_backend.dupelim.
 :- interface.
 
@@ -366,11 +366,11 @@
         Instr = restore_maxfr(Lval)
     ;
         Instr1 = incr_hp(Lval1, MaybeTag, MaybeOffset, Rval1, Msg,
-            MayUseAtomic),
+            MayUseAtomic, MaybeRegionRval),
         standardize_lval(Lval1, Lval),
         standardize_rval(Rval1, Rval),
         Instr = incr_hp(Lval, MaybeTag, MaybeOffset, Rval, Msg,
-            MayUseAtomic)
+            MayUseAtomic, MaybeRegionRval)
     ;
         Instr1 = mark_hp(Lval1),
         standardize_lval(Lval1, Lval),
@@ -629,19 +629,20 @@
         )
     ;
         Instr1 = incr_hp(Lval1, MaybeTag1, MaybeOffset1, Rval1, Msg1,
-            MayUseAtomic1),
+            MayUseAtomic1, MaybeRegionRval1),
         (
             Instr2 = incr_hp(Lval2, MaybeTag2, MaybeOffset2, Rval2, Msg2,
-                MayUseAtomic2),
+                MayUseAtomic2, MaybeRegionRval2),
             most_specific_lval(Lval1, Lval2, Lval),
             most_specific_rval(Rval1, Rval2, Rval),
             MaybeTag1 = MaybeTag2,
             MaybeOffset1 = MaybeOffset2,
             Msg1 = Msg2,
-            MayUseAtomic1 = MayUseAtomic2
+            MayUseAtomic1 = MayUseAtomic2,
+            MaybeRegionRval1 = MaybeRegionRval2
         ->
             MaybeInstr = yes(incr_hp(Lval, MaybeTag1, MaybeOffset1, Rval,
-                Msg1, MayUseAtomic1))
+                Msg1, MayUseAtomic1, MaybeRegionRval1))
         ;
             MaybeInstr = no
         )
Index: dupproc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dupproc.m,v
retrieving revision 1.18
diff -u -u -r1.18 dupproc.m
--- dupproc.m	18 Mar 2007 23:34:52 -0000	1.18
+++ dupproc.m	20 Jun 2007 06:42:23 -0000
@@ -230,7 +230,7 @@
         standardize_code_addr(Target, StdTarget, DupProcMap),
         StdInstr = if_val(StdRval, StdTarget)
     ;
-        Instr = incr_hp(_, _, _, _, _, _),
+        Instr = incr_hp(_, _, _, _, _, _, _),
         StdInstr = Instr
     ;
         Instr = mark_hp(_),
Index: exprn_aux.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/exprn_aux.m,v
retrieving revision 1.81
diff -u -u -r1.81 exprn_aux.m
--- exprn_aux.m	18 Mar 2007 23:34:52 -0000	1.81
+++ exprn_aux.m	20 Jun 2007 06:43:42 -0000
@@ -393,10 +393,12 @@
         Transform(Lval0, Lval, !Acc),
         Uinstr = restore_maxfr(Lval)
     ;
-        Uinstr0 = incr_hp(Lval0, MaybeTag, MO, Rval0, TypeCtor, MayUseAtomic),
+        Uinstr0 = incr_hp(Lval0, MaybeTag, MO, Rval0, TypeCtor,
+            MayUseAtomic, MaybeRegionRval),
         Transform(Lval0, Lval, !Acc),
         transform_lval_in_rval(Transform, Rval0, Rval, !Acc),
-        Uinstr = incr_hp(Lval, MaybeTag, MO, Rval, TypeCtor, MayUseAtomic)
+        Uinstr = incr_hp(Lval, MaybeTag, MO, Rval, TypeCtor,
+            MayUseAtomic, MaybeRegionRval)
     ;
         Uinstr0 = mark_hp(Lval0),
         Transform(Lval0, Lval, !Acc),
Index: global_data.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/global_data.m,v
retrieving revision 1.31
diff -u -u -r1.31 global_data.m
--- global_data.m	18 Mar 2007 23:34:52 -0000	1.31
+++ global_data.m	20 Jun 2007 06:44:31 -0000
@@ -931,7 +931,7 @@
         ; Instr0 = arbitrary_c_code(_, _, _)
         ; Instr0 = save_maxfr(_)
         ; Instr0 = restore_maxfr(_)
-        ; Instr0 = incr_hp(_, _, _, _, _, _)
+        ; Instr0 = incr_hp(_, _, _, _, _, _, _)
         ; Instr0 = mark_hp(_)
         ; Instr0 = restore_hp(_)
         ; Instr0 = free_heap(_)
Index: hlds_data.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_data.m,v
retrieving revision 1.113
diff -u -u -r1.113 hlds_data.m
--- hlds_data.m	7 May 2007 05:21:30 -0000	1.113
+++ hlds_data.m	20 Jun 2007 02:42:00 -0000
@@ -360,7 +360,7 @@
     % since atomic blocks are not scanned for included pointers. However,
     % this makes them safe to use *only* if the block allocated this way
     % can never contain any pointer the Boehm collector would be interested
-    % in tracing. In particular, it even if the cell initially contains no
+    % in tracing. In particular, even if the cell initially contains no
     % pointers, we must still use may_not_use_atomic_alloc for it if the cell
     % could possibly be reused later by compile-time garbage collection.
     %
Index: jumpopt.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/jumpopt.m,v
retrieving revision 1.103
diff -u -u -r1.103 jumpopt.m
--- jumpopt.m	18 Mar 2007 23:34:52 -0000	1.103
+++ jumpopt.m	20 Jun 2007 06:45:17 -0000
@@ -813,7 +813,7 @@
         ; Uinstr0 = mark_ticket_stack(_)
         ; Uinstr0 = mark_hp(_)
         ; Uinstr0 = free_heap(_)
-        ; Uinstr0 = incr_hp(_, _, _, _, _, _)
+        ; Uinstr0 = incr_hp(_, _, _, _, _, _, _)
         ; Uinstr0 = restore_hp(_)
         ; Uinstr0 = init_sync_term(_, _)
         ),
Index: livemap.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/livemap.m,v
retrieving revision 1.86
diff -u -u -r1.86 livemap.m
--- livemap.m	15 Jan 2007 02:23:47 -0000	1.86
+++ livemap.m	20 Jun 2007 06:45:59 -0000
@@ -230,7 +230,7 @@
         Uinstr0 = restore_maxfr(Lval),
         livemap.make_live_in_rval(lval(Lval), !Livevals)
     ;
-        Uinstr0 = incr_hp(Lval, _, _, Rval, _, _),
+        Uinstr0 = incr_hp(Lval, _, _, Rval, _, _, _),
 
         % Make dead the variable assigned, but make any variables
         % needed to access it live. Make the variables in the size
Index: llds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.347
diff -u -u -r1.347 llds.m
--- llds.m	18 Mar 2007 23:34:53 -0000	1.347
+++ llds.m	19 Jun 2007 06:58:09 -0000
@@ -321,14 +321,16 @@
             % lval was saved with save_maxfr.
 
     ;       incr_hp(lval, maybe(tag), maybe(int), rval, string,
-                may_use_atomic_alloc)
+                may_use_atomic_alloc, maybe(rval))
             % Get a memory block of a size given by an rval and put its address
             % in the given lval, possibly after incrementing it by N words
             % (if the maybe(int) is bound to `yes(N)') and/or after tagging it
             % with a given tag. The string gives the name of the type
             % constructor of the memory cell for use in memory profiling.
-            % The last argument says whether we can use the atomic variants
-            % of the Boehm gc allocator calls.
+            % The may_use_atomic_alloc argument says whether we can use the
+            % atomic variants of the Boehm gc allocator calls. The last
+            % argument says if the memory block is from a region or not, and
+            % if yes, from which region.
 
     ;       mark_hp(lval)
             % Tell the heap sub-system to store a marker (for later use in
Index: llds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.309
diff -u -u -r1.309 llds_out.m
--- llds_out.m	12 Jun 2007 06:06:29 -0000	1.309
+++ llds_out.m	20 Jun 2007 06:36:13 -0000
@@ -1955,9 +1955,16 @@
     output_lval_decls(Lval, !DeclSet, !IO).
 output_instr_decls(_, restore_maxfr(Lval), !DeclSet, !IO) :-
     output_lval_decls(Lval, !DeclSet, !IO).
-output_instr_decls(_, incr_hp(Lval, _Tag, _, Rval, _, _), !DeclSet, !IO) :-
+output_instr_decls(_, incr_hp(Lval, _Tag, _, Rval, _, _, MaybeRegionRval),
+        !DeclSet, !IO) :-
     output_lval_decls(Lval, !DeclSet, !IO),
-    output_rval_decls(Rval, !DeclSet, !IO).
+    output_rval_decls(Rval, !DeclSet, !IO),
+    (
+        MaybeRegionRval = yes(RegionRval),
+        output_rval_decls(RegionRval, !DeclSet, !IO)
+    ;
+        MaybeRegionRval = no
+    ).
 output_instr_decls(_, mark_hp(Lval), !DeclSet, !IO) :-
     output_lval_decls(Lval, !DeclSet, !IO).
 output_instr_decls(_, restore_hp(Rval), !DeclSet, !IO) :-
@@ -2388,111 +2395,134 @@
     io.write_string(");\n", !IO).
 
 output_instruction(incr_hp(Lval, MaybeTag, MaybeOffset, Rval, TypeMsg,
-        MayUseAtomicAlloc), ProfInfo, !IO) :-
-    globals.io_lookup_bool_option(profile_memory, ProfMem, !IO),
+        MayUseAtomicAlloc, MaybeRegionRval), ProfInfo, !IO) :-
     (
-        ProfMem = yes,
+        MaybeRegionRval = yes(RegionRval),
         (
             MaybeTag = no,
-            (
-                MayUseAtomicAlloc = may_not_use_atomic_alloc,
-                io.write_string("\tMR_offset_incr_hp_msg(", !IO)
-            ;
-                MayUseAtomicAlloc = may_use_atomic_alloc,
-                io.write_string("\tMR_offset_incr_hp_atomic_msg(", !IO)
-            ),
+            io.write_string("\tMR_alloc_in_region(", !IO),
             output_lval_as_word(Lval, !IO)
         ;
             MaybeTag = yes(Tag),
-            (
-                MayUseAtomicAlloc = may_not_use_atomic_alloc,
-                io.write_string("\tMR_tag_offset_incr_hp_msg(", !IO)
-            ;
-                MayUseAtomicAlloc = may_use_atomic_alloc,
-                io.write_string("\tMR_tag_offset_incr_hp_atomic_msg(", !IO)
-            ),
+            io.write_string("\tMR_tag_alloc_in_region(", !IO),
             output_lval_as_word(Lval, !IO),
             io.write_string(", ", !IO),
             output_tag(Tag, !IO)
         ),
         io.write_string(", ", !IO),
-        (
-            MaybeOffset = no,
-            io.write_string("0, ", !IO)
-        ;
-            MaybeOffset = yes(Offset),
-            io.write_int(Offset, !IO),
-            io.write_string(", ", !IO)
-        ),
-        output_rval_as_type(Rval, word, !IO),
+        output_rval(RegionRval, !IO),
         io.write_string(", ", !IO),
-        ProfInfo = CallerLabel - _,
-        output_label(CallerLabel, !IO),
-        io.write_string(", """, !IO),
-        c_util.output_quoted_string(TypeMsg, !IO),
-        io.write_string(""");\n", !IO)
+        output_rval_as_type(Rval, word, !IO),
+        io.write_string(");\n", !IO)
     ;
-        ProfMem = no,
+        MaybeRegionRval = no,
+        globals.io_lookup_bool_option(profile_memory, ProfMem, !IO),
         (
-            MaybeTag = no,
+            ProfMem = yes,
             (
-                MaybeOffset = yes(_),
+                MaybeTag = no,
                 (
                     MayUseAtomicAlloc = may_not_use_atomic_alloc,
-                    io.write_string("\tMR_offset_incr_hp(", !IO)
+                    io.write_string("\tMR_offset_incr_hp_msg(", !IO)
                 ;
                     MayUseAtomicAlloc = may_use_atomic_alloc,
-                    io.write_string("\tMR_offset_incr_hp_atomic(", !IO)
-                )
+                    io.write_string("\tMR_offset_incr_hp_atomic_msg(", !IO)
+                ),
+                output_lval_as_word(Lval, !IO)
             ;
-                MaybeOffset = no,
+                MaybeTag = yes(Tag),
                 (
                     MayUseAtomicAlloc = may_not_use_atomic_alloc,
-                    io.write_string("\tMR_alloc_heap(", !IO)
+                    io.write_string("\tMR_tag_offset_incr_hp_msg(", !IO)
                 ;
                     MayUseAtomicAlloc = may_use_atomic_alloc,
-                    io.write_string("\tMR_alloc_heap_atomic(", !IO)
-                )
+                    io.write_string(
+                        "\tMR_tag_offset_incr_hp_atomic_msg(", !IO)
+                ),
+                output_lval_as_word(Lval, !IO),
+                io.write_string(", ", !IO),
+                output_tag(Tag, !IO)
             ),
-            output_lval_as_word(Lval, !IO)
+            io.write_string(", ", !IO),
+            (
+                MaybeOffset = no,
+                io.write_string("0, ", !IO)
+            ;
+                MaybeOffset = yes(Offset),
+                io.write_int(Offset, !IO),
+                io.write_string(", ", !IO)
+            ),
+            output_rval_as_type(Rval, word, !IO),
+            io.write_string(", ", !IO),
+            ProfInfo = CallerLabel - _,
+            output_label(CallerLabel, !IO),
+            io.write_string(", """, !IO),
+            c_util.output_quoted_string(TypeMsg, !IO),
+            io.write_string(""");\n", !IO)
         ;
-            MaybeTag = yes(Tag),
+            ProfMem = no,
             (
-                MaybeOffset = yes(_),
+                MaybeTag = no,
                 (
-                    MayUseAtomicAlloc = may_not_use_atomic_alloc,
-                    io.write_string("\tMR_tag_offset_incr_hp(", !IO)
+                    MaybeOffset = yes(_),
+                    (
+                        MayUseAtomicAlloc = may_not_use_atomic_alloc,
+                        io.write_string("\tMR_offset_incr_hp(", !IO)
+                    ;
+                        MayUseAtomicAlloc = may_use_atomic_alloc,
+                        io.write_string("\tMR_offset_incr_hp_atomic(", !IO)
+                    )
                 ;
-                    MayUseAtomicAlloc = may_use_atomic_alloc,
-                    io.write_string("\tMR_tag_offset_incr_hp_atomic(", !IO)
+                    MaybeOffset = no,
+                    (
+                        MayUseAtomicAlloc = may_not_use_atomic_alloc,
+                        io.write_string("\tMR_alloc_heap(", !IO)
+                    ;
+                        MayUseAtomicAlloc = may_use_atomic_alloc,
+                        io.write_string("\tMR_alloc_heap_atomic(", !IO)
+                    )
                 ),
-                output_lval_as_word(Lval, !IO),
-                io.write_string(", ", !IO),
-                output_tag(Tag, !IO)
+                output_lval_as_word(Lval, !IO)
             ;
-                MaybeOffset = no,
+                MaybeTag = yes(Tag),
                 (
-                    MayUseAtomicAlloc = may_not_use_atomic_alloc,
-                    io.write_string("\tMR_tag_alloc_heap(", !IO)
+                    MaybeOffset = yes(_),
+                    (
+                        MayUseAtomicAlloc = may_not_use_atomic_alloc,
+                        io.write_string("\tMR_tag_offset_incr_hp(", !IO)
+                    ;
+                        MayUseAtomicAlloc = may_use_atomic_alloc,
+                        io.write_string(
+                            "\tMR_tag_offset_incr_hp_atomic(", !IO)
+                    ),
+                    output_lval_as_word(Lval, !IO),
+                    io.write_string(", ", !IO),
+                    output_tag(Tag, !IO)
                 ;
-                    MayUseAtomicAlloc = may_use_atomic_alloc,
-                    io.write_string("\tMR_tag_alloc_heap_atomic(", !IO)
-                ),
-                output_lval_as_word(Lval, !IO),
-                io.write_string(", ", !IO),
-                io.write_int(Tag, !IO)
-            )
-        ),
-        io.write_string(", ", !IO),
-        (
-            MaybeOffset = yes(Offset),
-            io.write_int(Offset, !IO),
-            io.write_string(", ", !IO)
-        ;
-            MaybeOffset = no
-        ),
-        output_rval_as_type(Rval, word, !IO),
-        io.write_string(");\n", !IO)
+                    MaybeOffset = no,
+                    (
+                        MayUseAtomicAlloc = may_not_use_atomic_alloc,
+                        io.write_string("\tMR_tag_alloc_heap(", !IO)
+                    ;
+                        MayUseAtomicAlloc = may_use_atomic_alloc,
+                        io.write_string("\tMR_tag_alloc_heap_atomic(", !IO)
+                    ),
+                    output_lval_as_word(Lval, !IO),
+                    io.write_string(", ", !IO),
+                    io.write_int(Tag, !IO)
+                )
+            ),
+            io.write_string(", ", !IO),
+            (
+                MaybeOffset = yes(Offset),
+                io.write_int(Offset, !IO),
+                io.write_string(", ", !IO)
+            ;
+                MaybeOffset = no
+            ),
+            output_rval_as_type(Rval, word, !IO),
+            io.write_string(");\n", !IO)
+        )
     ).
 
 output_instruction(mark_hp(Lval), _, !IO) :-
Index: llds_to_x86_64.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds_to_x86_64.m,v
retrieving revision 1.3
diff -u -u -r1.3 llds_to_x86_64.m
--- llds_to_x86_64.m	18 Mar 2007 23:34:54 -0000	1.3
+++ llds_to_x86_64.m	20 Jun 2007 06:46:54 -0000
@@ -344,7 +344,7 @@
     Instr = [x86_64_comment("<<save_maxfr>>")].
 instr_to_x86_64(RegMap, restore_maxfr(_), RegMap, Instr) :-
     Instr = [x86_64_comment("<<restore_maxfr>>")].
-instr_to_x86_64(RegMap0, incr_hp(Lval, Tag0, Words0, Rval, _, _), RegMap, 
+instr_to_x86_64(RegMap0, incr_hp(Lval, Tag0, Words0, Rval, _, _, _), RegMap, 
         Instrs) :-
     transform_rval(RegMap0, Rval, RegMap1, Res0, Res1),
     transform_lval(RegMap1, Lval, RegMap2, Res2, Res3),
Index: middle_rec.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/middle_rec.m,v
retrieving revision 1.128
diff -u -u -r1.128 middle_rec.m
--- middle_rec.m	6 Jan 2007 09:23:41 -0000	1.128
+++ middle_rec.m	20 Jun 2007 06:51:13 -0000
@@ -522,9 +522,16 @@
     find_used_registers_lval(Lval, !Used).
 find_used_registers_instr(restore_maxfr(Lval), !Used) :-
     find_used_registers_lval(Lval, !Used).
-find_used_registers_instr(incr_hp(Lval, _, _, Rval, _, _), !Used) :-
+find_used_registers_instr(incr_hp(Lval, _, _, Rval, _, _, MaybeRegionRval),
+        !Used) :-
     find_used_registers_lval(Lval, !Used),
-    find_used_registers_rval(Rval, !Used).
+    find_used_registers_rval(Rval, !Used),
+    (
+        MaybeRegionRval = yes(RegionRval),
+        find_used_registers_rval(RegionRval, !Used)
+    ;
+        MaybeRegionRval = no
+    ).
 find_used_registers_instr(mark_hp(Lval), !Used) :-
     find_used_registers_lval(Lval, !Used).
 find_used_registers_instr(restore_hp(Rval), !Used) :-
Index: opt_debug.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/opt_debug.m,v
retrieving revision 1.193
diff -u -u -r1.193 opt_debug.m
--- opt_debug.m	12 Jun 2007 06:06:29 -0000	1.193
+++ opt_debug.m	20 Jun 2007 06:52:19 -0000
@@ -724,7 +724,7 @@
         Instr = restore_maxfr(Lval),
         Str = "restore_maxfr(" ++ dump_lval(yes(ProcLabel), Lval) ++ ")"
     ;
-        Instr = incr_hp(Lval, MaybeTag, MaybeOffset, Size, _, MayUseAtomic),
+        Instr = incr_hp(Lval, MaybeTag, MaybeOffset, Size, _, MayUseAtomic, _),
         (
             MaybeTag = no,
             T_str = "no"
Index: opt_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/opt_util.m,v
retrieving revision 1.163
diff -u -u -r1.163 opt_util.m
--- opt_util.m	18 Mar 2007 23:34:56 -0000	1.163
+++ opt_util.m	20 Jun 2007 07:11:07 -0000
@@ -683,7 +683,7 @@
             ( Uinstr = comment(_)
             ; Uinstr = livevals(_)
             ; Uinstr = if_val(_, _)
-            ; Uinstr = incr_hp(_, _, _, _, _, _)
+            ; Uinstr = incr_hp(_, _, _, _, _, _, _)
             ; Uinstr = mark_hp(_)
             ; Uinstr = restore_hp(_)
             ; Uinstr = free_heap(_)
@@ -813,9 +813,15 @@
             Between = [Instr0 | Between0]
         )
     ;
-        Uinstr0 = incr_hp(Lval, _, _, Rval, _, _),
+        Uinstr0 = incr_hp(Lval, _, _, Rval, _, _, MaybeRegionRval),
         lval_refers_stackvars(Lval) = no,
         rval_refers_stackvars(Rval) = no,
+        (
+            MaybeRegionRval = yes(RegionRval),
+            rval_refers_stackvars(RegionRval) = no
+        ;
+            MaybeRegionRval = no
+        ),
         no_stackvars_til_decr_sp(Instrs0, FrameSize, Between0, Remain),
         Between = [Instr0 | Between0]
     ;
@@ -885,10 +891,20 @@
         Uinstr = restore_maxfr(Lval),
         Refers = lval_refers_stackvars(Lval)
     ;
-        Uinstr = incr_hp(Lval, _, _, Rval, _, _),
-        Refers = bool.or(
-            lval_refers_stackvars(Lval),
-            rval_refers_stackvars(Rval))
+        Uinstr = incr_hp(Lval, _, _, Rval, _, _, MaybeRegionRval),
+        (
+            MaybeRegionRval = no,
+            Refers = bool.or(
+                lval_refers_stackvars(Lval),
+                rval_refers_stackvars(Rval))
+        ;
+            MaybeRegionRval = yes(RegionRval),
+            Refers0 = bool.or(
+                lval_refers_stackvars(Lval),
+                rval_refers_stackvars(Rval)),
+            Refers = bool.or(Refers0,
+                rval_refers_stackvars(RegionRval))
+        )
     ;
         Uinstr = mark_hp(Lval),
         Refers = lval_refers_stackvars(Lval)
@@ -1054,7 +1070,7 @@
 can_instr_branch_away(if_val(_, _)) = yes.
 can_instr_branch_away(save_maxfr(_)) = no.
 can_instr_branch_away(restore_maxfr(_)) = no.
-can_instr_branch_away(incr_hp(_, _, _, _, _, _)) = no.
+can_instr_branch_away(incr_hp(_, _, _, _, _, _, _)) = no.
 can_instr_branch_away(mark_hp(_)) = no.
 can_instr_branch_away(restore_hp(_)) = no.
 can_instr_branch_away(free_heap(_)) = no.
@@ -1128,7 +1144,7 @@
 can_instr_fall_through(if_val(_, _)) = yes.
 can_instr_fall_through(save_maxfr(_)) = yes.
 can_instr_fall_through(restore_maxfr(_)) = yes.
-can_instr_fall_through(incr_hp(_, _, _, _, _, _)) = yes.
+can_instr_fall_through(incr_hp(_, _, _, _, _, _, _)) = yes.
 can_instr_fall_through(mark_hp(_)) = yes.
 can_instr_fall_through(restore_hp(_)) = yes.
 can_instr_fall_through(free_heap(_)) = yes.
@@ -1174,7 +1190,7 @@
 can_use_livevals(if_val(_, _), yes).
 can_use_livevals(save_maxfr(_), no).
 can_use_livevals(restore_maxfr(_), no).
-can_use_livevals(incr_hp(_, _, _, _, _, _), no).
+can_use_livevals(incr_hp(_, _, _, _, _, _, _), no).
 can_use_livevals(mark_hp(_), no).
 can_use_livevals(restore_hp(_), no).
 can_use_livevals(free_heap(_), no).
@@ -1237,7 +1253,7 @@
 instr_labels_2(if_val(_, Addr), [], [Addr]).
 instr_labels_2(save_maxfr(_), [], []).
 instr_labels_2(restore_maxfr(_), [], []).
-instr_labels_2(incr_hp(_, _, _, _, _, _), [], []).
+instr_labels_2(incr_hp(_, _, _, _, _, _, _), [], []).
 instr_labels_2(mark_hp(_), [], []).
 instr_labels_2(restore_hp(_), [], []).
 instr_labels_2(free_heap(_), [], []).
@@ -1298,7 +1314,7 @@
     ).
 possible_targets(save_maxfr(_), [], []).
 possible_targets(restore_maxfr(_), [], []).
-possible_targets(incr_hp(_, _, _, _, _, _), [], []).
+possible_targets(incr_hp(_, _, _, _, _, _, _), [], []).
 possible_targets(mark_hp(_), [], []).
 possible_targets(restore_hp(_), [], []).
 possible_targets(free_heap(_), [], []).
@@ -1371,7 +1387,15 @@
 instr_rvals_and_lvals(if_val(Rval, _), [Rval], []).
 instr_rvals_and_lvals(save_maxfr(Lval), [], [Lval]).
 instr_rvals_and_lvals(restore_maxfr(Lval), [], [Lval]).
-instr_rvals_and_lvals(incr_hp(Lval, _, _, Rval, _, _), [Rval], [Lval]).
+instr_rvals_and_lvals(incr_hp(Lval, _, _, Rval, _, _, MaybeRegionRval),
+        Rvals, [Lval]) :-
+    (
+        MaybeRegionRval = yes(RegionRval),
+        Rvals = [Rval, RegionRval]
+    ;
+        MaybeRegionRval = no,
+        Rvals = [Rval]
+    ).
 instr_rvals_and_lvals(mark_hp(Lval), [], [Lval]).
 instr_rvals_and_lvals(restore_hp(Rval), [Rval], []).
 instr_rvals_and_lvals(free_heap(Rval), [Rval], []).
@@ -1507,9 +1531,15 @@
     count_temps_lval(Lval, !R, !F).
 count_temps_instr(restore_maxfr(Lval), !R, !F) :-
     count_temps_lval(Lval, !R, !F).
-count_temps_instr(incr_hp(Lval, _, _, Rval, _, _), !R, !F) :-
+count_temps_instr(incr_hp(Lval, _, _, Rval, _, _, MaybeRegionRval), !R, !F) :-
     count_temps_lval(Lval, !R, !F),
-    count_temps_rval(Rval, !R, !F).
+    count_temps_rval(Rval, !R, !F),
+    (
+        MaybeRegionRval = yes(RegionRval),
+        count_temps_rval(RegionRval, !R, !F)
+    ;
+        MaybeRegionRval = no
+    ).
 count_temps_instr(mark_hp(Lval), !R, !F) :-
     count_temps_lval(Lval, !R, !F).
 count_temps_instr(restore_hp(Rval), !R, !F) :-
@@ -1698,10 +1728,18 @@
         TouchRval = touches_nondet_ctrl_rval(Rval),
         bool.or(TouchLval, TouchRval, Touch)
     ;
-        Uinstr = incr_hp(Lval, _, _, Rval, _, _),
+        Uinstr = incr_hp(Lval, _, _, Rval, _, _, MaybeRegionRval),
         TouchLval = touches_nondet_ctrl_lval(Lval),
         TouchRval = touches_nondet_ctrl_rval(Rval),
-        bool.or(TouchLval, TouchRval, Touch)
+        (
+            MaybeRegionRval = yes(RegionRval),
+            TouchRegionRval = touches_nondet_ctrl_rval(RegionRval)
+        ;
+            MaybeRegionRval = no,
+            TouchRegionRval = no
+        ),
+        bool.or(TouchLval, TouchRval, Touch0),
+        bool.or(Touch0, TouchRegionRval, Touch)
     ;
         Uinstr = mark_hp(Lval),
         Touch = touches_nondet_ctrl_lval(Lval)
@@ -1842,7 +1880,7 @@
 
 count_incr_hp_2([], !N).
 count_incr_hp_2([llds_instr(Uinstr0, _) | Instrs], !N) :-
-    ( Uinstr0 = incr_hp(_, _, _, _, _, _) ->
+    ( Uinstr0 = incr_hp(_, _, _, _, _, _, _) ->
         !:N = !.N + 1
     ;
         true
@@ -1989,16 +2027,27 @@
         ReplData = no,
         Lval = Lval0
     ).
-replace_labels_instr(incr_hp(Lval0, MaybeTag, MO, Rval0, Msg, Atomic),
-        ReplMap, ReplData, incr_hp(Lval, MaybeTag, MO, Rval, Msg, Atomic)) :-
+replace_labels_instr(
+        incr_hp(Lval0, MaybeTag, MO, Rval0, Msg, Atomic, MaybeRegionRval0),
+        ReplMap, ReplData,
+        incr_hp(Lval, MaybeTag, MO, Rval, Msg, Atomic, MaybeRegionRval)) :-
     (
         ReplData = yes,
         replace_labels_lval(Lval0, ReplMap, Lval),
-        replace_labels_rval(Rval0, ReplMap, Rval)
+        replace_labels_rval(Rval0, ReplMap, Rval),
+        (
+            MaybeRegionRval0 = yes(RegionRval0),
+            replace_labels_rval(RegionRval0, ReplMap, RegionRval),
+            MaybeRegionRval = yes(RegionRval)
+        ;
+            MaybeRegionRval0 = no,
+            MaybeRegionRval = MaybeRegionRval0
+        )
     ;
         ReplData = no,
         Lval = Lval0,
-        Rval = Rval0
+        Rval = Rval0,
+        MaybeRegionRval = MaybeRegionRval0
     ).
 replace_labels_instr(mark_hp(Lval0), ReplMap, ReplData,
         mark_hp(Lval)) :-
Index: par_conj_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/par_conj_gen.m,v
retrieving revision 1.31
diff -u -u -r1.31 par_conj_gen.m
--- par_conj_gen.m	6 Jan 2007 09:23:46 -0000	1.31
+++ par_conj_gen.m	20 Jun 2007 07:12:17 -0000
@@ -192,7 +192,7 @@
     MakeSyncTermCode = node([
         % The may_not_use_atomic here is conservative.
         llds_instr(incr_hp(RegLval, no, no, const(llconst_int(STSize)),
-            "sync term", may_not_use_atomic_alloc),
+            "sync term", may_not_use_atomic_alloc, no),
             "allocate a sync term"),
         llds_instr(init_sync_term(RegLval, NumGoals),
             "initialize sync term"),
Index: rbmm.interproc_region_lifetime.m
===================================================================
RCS file:
/home/mercury/mercury1/repository/mercury/compiler/rbmm.interproc_region_lifetime.m,v
retrieving revision 1.1
diff -u -u -r1.1 rbmm.interproc_region_lifetime.m
--- rbmm.interproc_region_lifetime.m	23 May 2007 00:17:19 -0000	1.1
+++ rbmm.interproc_region_lifetime.m	28 Jun 2007 04:29:42 -0000
@@ -597,18 +597,12 @@
     rptg_node::in, region_set::in, region_set::out) is det.
 
 retain_non_primitive_regions(ModuleInfo, Graph, Region, !RegionSet) :-
-	rptg_node_contents(Graph, Region, Content),
-	rptg_node_content_get_node_type(Content, NodeType),
-	( 
-		type_is_atomic(ModuleInfo, NodeType)
-	  ->
-		true
-	  ;
-		is_dummy_argument_type(ModuleInfo, NodeType)
-	  ->
-		true
-	  ;
-		svset.insert(Region, !RegionSet)
+	NodeType = rptg_lookup_node_type(Graph, Region),
+	(   ( type_is_atomic(ModuleInfo, NodeType) 
+	    ; is_dummy_argument_type(ModuleInfo, NodeType)
+        )
+	->  true
+	;   svset.insert(Region, !RegionSet)
 	).
 
     % Eliminate regions of primitive types from the 

Index: reassign.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/reassign.m,v
retrieving revision 1.23
diff -u -u -r1.23 reassign.m
--- reassign.m	6 Jan 2007 09:23:50 -0000	1.23
+++ reassign.m	20 Jun 2007 07:13:23 -0000
@@ -220,7 +220,7 @@
         !:RevInstrs = [Instr0 | !.RevInstrs],
         clobber_dependents(hp, !KnownContentsMap, !DepLvalMap)
     ;
-        Uinstr0 = incr_hp(Target, _, _, _, _, _),
+        Uinstr0 = incr_hp(Target, _, _, _, _, _, _),
         !:RevInstrs = [Instr0 | !.RevInstrs],
         clobber_dependents(Target, !KnownContentsMap, !DepLvalMap),
         clobber_dependents(hp, !KnownContentsMap, !DepLvalMap)
Index: unify_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unify_gen.m,v
retrieving revision 1.179
diff -u -u -r1.179 unify_gen.m
--- unify_gen.m	19 Jan 2007 07:04:34 -0000	1.179
+++ unify_gen.m	20 Jun 2007 07:22:13 -0000
@@ -100,7 +100,7 @@
             Code = empty
         )
     ;
-        Uni = construct(Var, ConsId, Args, Modes, _, _, SubInfo),
+        Uni = construct(Var, ConsId, Args, Modes, HowToConstruct, _, SubInfo),
         (
             SubInfo = no_construct_sub_info,
             MaybeTakeAddr = no,
@@ -119,7 +119,7 @@
                 MaybeTakeAddr = no,
                 TakeAddr = []
             ),
-            generate_construction(Var, ConsId, Args, Modes,
+            generate_construction(Var, ConsId, Args, Modes, HowToConstruct,
                 TakeAddr, MaybeSize, GoalInfo, Code, !CI)
         ;
             Code = empty
@@ -355,29 +355,29 @@
     % of a function symbol if the function symbol has arity zero.
     % If the function symbol's arity is greater than zero, and all its
     % arguments are constants, the construction is implemented by
-    % constructing the new term statically. If not all the argumemts are
+    % constructing the new term statically. If not all the arguments are
     % constants, the construction is implemented as a heap-increment
     % to create a term, and a series of [optional] assignments to
     % instantiate the arguments of that term.
     %
 :- pred generate_construction(prog_var::in, cons_id::in,
-    list(prog_var)::in, list(uni_mode)::in, list(int)::in,
-    maybe(term_size_value)::in, hlds_goal_info::in, code_tree::out,
-    code_info::in, code_info::out) is det.
+    list(prog_var)::in, list(uni_mode)::in, how_to_construct::in,
+    list(int)::in, maybe(term_size_value)::in, hlds_goal_info::in,
+    code_tree::out, code_info::in, code_info::out) is det.
 
-generate_construction(Var, ConsId, Args, Modes, TakeAddr, MaybeSize, GoalInfo,
-        Code, !CI) :-
+generate_construction(Var, ConsId, Args, Modes, HowToConstruct,
+        TakeAddr, MaybeSize, GoalInfo, Code, !CI) :-
     Tag = cons_id_to_tag_for_var(!.CI, Var, ConsId),
-    generate_construction_2(Tag, Var, Args, Modes, TakeAddr, MaybeSize,
-        GoalInfo, Code, !CI).
+    generate_construction_2(Tag, Var, Args, Modes, HowToConstruct,
+        TakeAddr, MaybeSize, GoalInfo, Code, !CI).
 
 :- pred generate_construction_2(cons_tag::in, prog_var::in,
-    list(prog_var)::in, list(uni_mode)::in, list(int)::in,
-    maybe(term_size_value)::in, hlds_goal_info::in, code_tree::out,
-    code_info::in, code_info::out) is det.
+    list(prog_var)::in, list(uni_mode)::in, how_to_construct::in,
+    list(int)::in, maybe(term_size_value)::in, hlds_goal_info::in,
+    code_tree::out, code_info::in, code_info::out) is det.
 
-generate_construction_2(ConsTag, Var, Args, Modes, TakeAddr, MaybeSize,
-        GoalInfo, Code, !CI) :-
+generate_construction_2(ConsTag, Var, Args, Modes, HowToConstruct,
+        TakeAddr, MaybeSize, GoalInfo, Code, !CI) :-
     (
         ConsTag = string_tag(String),
         code_info.assign_const_to_var(Var, const(llconst_string(String)), !CI),
@@ -412,15 +412,15 @@
     ;
         ConsTag = single_functor_tag,
         % Treat single_functor the same as unshared_tag(0).
-        generate_construction_2(unshared_tag(0),
-            Var, Args, Modes, TakeAddr, MaybeSize, GoalInfo, Code, !CI)
+        generate_construction_2(unshared_tag(0), Var, Args, Modes,
+            HowToConstruct, TakeAddr, MaybeSize, GoalInfo, Code, !CI)
     ;
         ConsTag = unshared_tag(Ptag),
         var_types(!.CI, Args, ArgTypes),
         generate_cons_args(Args, ArgTypes, Modes, 0, 1, TakeAddr, !.CI,
             MaybeRvals, FieldAddrs, MayUseAtomic),
-        construct_cell(Var, Ptag, MaybeRvals, MaybeSize, FieldAddrs,
-            MayUseAtomic, Code, !CI)
+        construct_cell(Var, Ptag, MaybeRvals, HowToConstruct,
+            MaybeSize, FieldAddrs, MayUseAtomic, Code, !CI)
     ;
         ConsTag = shared_remote_tag(Ptag, Sectag),
         var_types(!.CI, Args, ArgTypes),
@@ -428,8 +428,8 @@
             MaybeRvals0, FieldAddrs, MayUseAtomic),
         % The first field holds the secondary tag.
         MaybeRvals = [yes(const(llconst_int(Sectag))) | MaybeRvals0],
-        construct_cell(Var, Ptag, MaybeRvals, MaybeSize, FieldAddrs,
-            MayUseAtomic, Code, !CI)
+        construct_cell(Var, Ptag, MaybeRvals, HowToConstruct,
+            MaybeSize, FieldAddrs, MayUseAtomic, Code, !CI)
     ;
         ConsTag = shared_local_tag(Bits1, Num1),
         code_info.assign_const_to_var(Var,
@@ -506,7 +506,8 @@
         % for tag tests, not for constructions, so here we just recurse
         % on the real representation.
         generate_construction_2(ThisTag,
-            Var, Args, Modes, TakeAddr, MaybeSize, GoalInfo, Code, !CI)
+            Var, Args, Modes, HowToConstruct, TakeAddr, MaybeSize, GoalInfo,
+            Code, !CI)
     ;
         ConsTag = pred_closure_tag(PredId, ProcId, EvalMethod),
         expect(unify(TakeAddr, []), this_file,
@@ -612,7 +613,7 @@
                     "get number of arguments"),
                 llds_instr(incr_hp(NewClosure, no, no,
                     binop(int_add, lval(NumOldArgs), NumNewArgsPlusThree_Rval),
-                    "closure", NewClosureMayUseAtomic),
+                    "closure", NewClosureMayUseAtomic, no),
                     "allocate new closure"),
                 llds_instr(assign(field(yes(0), lval(NewClosure), Zero),
                     lval(field(yes(0), OldClosure, Zero))),
@@ -698,8 +699,10 @@
             yes(const(llconst_int(NumArgs)))
             | PredArgs
         ],
-        code_info.assign_cell_to_var(Var, no, 0, Vector, no, [], "closure",
-            MayUseAtomic, Code, !CI)
+        % construct_dynamically is just a dummy value. We just want something
+        % which is not construct_in_region(_).
+        code_info.assign_cell_to_var(Var, no, 0, Vector,
+            construct_dynamically, no, [], "closure", MayUseAtomic, Code, !CI)
     ).
 
 :- pred generate_extra_closure_args(list(prog_var)::in, lval::in,
@@ -825,12 +828,12 @@
     ).
 
 :- pred construct_cell(prog_var::in, tag::in, list(maybe(rval))::in,
-    maybe(term_size_value)::in, assoc_list(int, prog_var)::in,
-    may_use_atomic_alloc::in, code_tree::out, code_info::in, code_info::out)
-    is det.
+    how_to_construct::in, maybe(term_size_value)::in,
+    assoc_list(int, prog_var)::in, may_use_atomic_alloc::in,
+    code_tree::out, code_info::in, code_info::out) is det.
 
-construct_cell(Var, Ptag, MaybeRvals, MaybeSize, FieldAddrs, MayUseAtomic,
-        Code, !CI) :-
+construct_cell(Var, Ptag, MaybeRvals, HowToConstruct, MaybeSize, FieldAddrs,
+        MayUseAtomic, Code, !CI) :-
     VarType = code_info.variable_type(!.CI, Var),
     var_type_msg(VarType, VarTypeMsg),
     % If we're doing accurate GC, then for types which hold RTTI that
@@ -851,7 +854,8 @@
     ),
     FieldNums = list.map(fst, FieldAddrs),
     code_info.assign_cell_to_var(Var, ReserveWordAtStart, Ptag, MaybeRvals,
-        MaybeSize, FieldNums, VarTypeMsg, MayUseAtomic, CellCode, !CI),
+        HowToConstruct, MaybeSize, FieldNums, VarTypeMsg, MayUseAtomic,
+        CellCode, !CI),
     (
         FieldAddrs = [],
         % Optimize common case.
Index: use_local_vars.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/use_local_vars.m,v
retrieving revision 1.33
diff -u -u -r1.33 use_local_vars.m
--- use_local_vars.m	15 Jan 2007 02:23:51 -0000	1.33
+++ use_local_vars.m	20 Jun 2007 07:25:11 -0000
@@ -177,7 +177,7 @@
                 Uinstr0 = assign(ToLval, _FromRval)
             ;
                 Uinstr0 = incr_hp(ToLval, _MaybeTag, _SizeRval, _MO, _Type,
-                    _Atomic)
+                    _Atomic, _)
             ),
             base_lval_worth_replacing(NumRealRRegs, ToLval),
             MaybeMore = no
@@ -478,10 +478,12 @@
         expect(unify(ToLval, OldLval),
             this_file, "substitute_lval_in_defn: mismatch in assign"),
         Uinstr = assign(NewLval, FromRval)
-    ; Uinstr0 = incr_hp(ToLval, MaybeTag, SizeRval, MO, Type, MayUseAtomic) ->
+    ; Uinstr0 = incr_hp(ToLval, MaybeTag, SizeRval, MO, Type,
+                            MayUseAtomic, MaybeRegionRval) ->
         expect(unify(ToLval, OldLval),
             this_file, "substitute_lval_in_defn: mismatch in incr_hp"),
-        Uinstr = incr_hp(NewLval, MaybeTag, SizeRval, MO, Type, MayUseAtomic)
+        Uinstr = incr_hp(NewLval, MaybeTag, SizeRval, MO, Type,
+                            MayUseAtomic, MaybeRegionRval)
     ; Uinstr0 = foreign_proc_code(D, Comps0, MCM, FNL, FL, FOL, NF, S, MD) ->
         substitute_lval_in_defn_components(OldLval, NewLval, Comps0, Comps,
             0, NumSubsts),
@@ -588,7 +590,7 @@
             substitute_lval_in_instr_until_defn(OldLval, NewLval, !Instrs, !N)
         )
     ;
-        Uinstr0 = incr_hp(Lval, _, _, _, _, _),
+        Uinstr0 = incr_hp(Lval, _, _, _, _, _, _),
         ( assignment_updates_oldlval(Lval, OldLval) = yes ->
             % If we alter any lval that occurs in OldLval, we must stop
             % the substitutions.
Index: var_locn.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/var_locn.m,v
retrieving revision 1.50
diff -u -u -r1.50 var_locn.m
--- var_locn.m	19 Jan 2007 07:04:35 -0000	1.50
+++ var_locn.m	20 Jun 2007 07:28:30 -0000
@@ -183,7 +183,8 @@
     % obvious conflict.)
     %
 :- pred var_locn_assign_cell_to_var(module_info::in, prog_var::in, bool::in,
-    tag::in, list(maybe(rval))::in, maybe(term_size_value)::in, list(int)::in,
+    tag::in, list(maybe(rval))::in, how_to_construct::in,
+    maybe(term_size_value)::in, list(int)::in,
     string::in, may_use_atomic_alloc::in, code_tree::out,
     static_cell_info::in, static_cell_info::out,
     var_locn_info::in, var_locn_info::out) is det.
@@ -818,8 +819,8 @@
 %----------------------------------------------------------------------------%
 
 var_locn_assign_cell_to_var(ModuleInfo, Var, ReserveWordAtStart, Ptag,
-        MaybeRvals0, MaybeSize, FieldAddrs, TypeMsg, MayUseAtomic, Code,
-        !StaticCellInfo, !VLI) :-
+        MaybeRvals0, HowToConstruct, MaybeSize, FieldAddrs, TypeMsg,
+        MayUseAtomic, Code, !StaticCellInfo, !VLI) :-
     (
         MaybeSize = yes(SizeSource),
         (
@@ -851,17 +852,18 @@
         Code = empty
     ;
         var_locn_assign_dynamic_cell_to_var(ModuleInfo, Var,
-            ReserveWordAtStart, Ptag, MaybeRvals, MaybeOffset, TypeMsg,
-            MayUseAtomic, Code, !VLI)
+            ReserveWordAtStart, Ptag, MaybeRvals, HowToConstruct,
+            MaybeOffset, TypeMsg, MayUseAtomic, Code, !VLI)
     ).
 
 :- pred var_locn_assign_dynamic_cell_to_var(module_info::in, prog_var::in,
-    bool::in, tag::in, list(maybe(rval))::in, maybe(int)::in, string::in,
-    may_use_atomic_alloc::in, code_tree::out,
+    bool::in, tag::in, list(maybe(rval))::in, how_to_construct::in,
+    maybe(int)::in, string::in, may_use_atomic_alloc::in, code_tree::out,
     var_locn_info::in, var_locn_info::out) is det.
 
 var_locn_assign_dynamic_cell_to_var(ModuleInfo, Var, ReserveWordAtStart, Ptag,
-        Vector, MaybeOffset, TypeMsg, MayUseAtomic, Code, !VLI) :-
+        Vector, HowToConstruct, MaybeOffset, TypeMsg, MayUseAtomic, Code,
+        !VLI) :-
     check_var_is_unknown(!.VLI, Var),
 
     select_preferred_reg_or_stack_check(!.VLI, Var, Lval),
@@ -884,11 +886,26 @@
         TotalOffset = MaybeOffset,
         TotalSize = Size
     ),
+    (
+        HowToConstruct = construct_in_region(RegionVar),
+        var_locn_produce_var(ModuleInfo, RegionVar, RegionRval,
+            RegionVarCode, !VLI),
+        MaybeRegionRval = yes(RegionRval),
+        LldsComment = "Allocating region for "
+    ;
+        ( HowToConstruct = construct_statically(_)
+        ; HowToConstruct = construct_dynamically
+        ; HowToConstruct = reuse_cell(_)
+        ),
+        RegionVarCode = empty,
+        MaybeRegionRval = no,
+        LldsComment = "Allocating heap for "
+    ),
     CellCode = node([
         llds_instr(
             incr_hp(Lval, yes(Ptag), TotalOffset,
-                const(llconst_int(TotalSize)), TypeMsg, MayUseAtomic),
-            "Allocating heap for " ++ VarName)
+                const(llconst_int(TotalSize)), TypeMsg, MayUseAtomic,
+                MaybeRegionRval), LldsComment ++ VarName)
     ]),
     var_locn_set_magic_var_location(Var, Lval, !VLI),
     (
@@ -900,7 +917,7 @@
     ),
     assign_cell_args(ModuleInfo, Vector, yes(Ptag), lval(Lval), StartOffset,
         ArgsCode, !VLI),
-    Code = tree(CellCode, ArgsCode).
+    Code = tree_list([CellCode, RegionVarCode, ArgsCode]).
 
 :- pred assign_cell_args(module_info::in, list(maybe(rval))::in,
     maybe(tag)::in, rval::in, int::in, code_tree::out,

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