[m-rev.] For review: Use type for region instruction

Quan Phan Quan.Phan at cs.kuleuven.be
Thu Jul 19 21:26:14 AEST 2007


Hi,

Estimated hours taken: 2.
Branches: main.

Defining and using a specific type for region instructions (instead of string).


compiler/rbmm.region_instruction.m:
        Define the new type for region instructions and modify the code to use
        it.

compiler/rbmm.region_transformation.m:
        Modify the code to use the new type. Move the function that returns
        builtin region type to prog_type.m.

compiler/rbmm.condition_renaming.m
compiler/rbmm.region_resurrection_renaming.m:
        Change the code to use the new type and correct some formatting.

compiler/rbmm.m:
        Change a variable name and some alignment of source code.

compiler/prog_type.m:
        Add a function to return the builtin region type.

Regards,
Quan

Index: rbmm.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rbmm.m,v
retrieving revision 1.5
diff -u -u -r1.5 rbmm.m
--- rbmm.m	6 Jul 2007 02:35:23 -0000	1.5
+++ rbmm.m	19 Jul 2007 05:56:03 -0000
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% vim: ft=mercury ts=4 sw=4
+% vim: ft=mercury ts=4 sw=4 et
 %-----------------------------------------------------------------------------%
 % Copyright (C) 2007 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
@@ -37,7 +37,7 @@
 %-----------------------------------------------------------------------------%
 
 :- pred do_region_analysis(module_info::in, module_info::out,
-	io::di, io::uo) is det.
+    io::di, io::uo) is det.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -64,58 +64,58 @@
     live_variable_analysis(!.ModuleInfo, ExecPathTable, LVBeforeTable, 
         LVAfterTable, VoidVarTable),
     live_region_analysis(!.ModuleInfo, RptaInfoTable, 
-		LVBeforeTable, LVAfterTable, VoidVarTable, LRBeforeTable0,
-		LRAfterTable0, VoidVarRegionTable0, InputRTable, OutputRTable,
-		BornRTable0, DeadRTable0, LocalRTable0),
+        LVBeforeTable, LVAfterTable, VoidVarTable, LRBeforeTable0,
+        LRAfterTable0, VoidVarRegionTable0, InputRTable, OutputRTable,
+        BornRTable0, DeadRTable0, LocalRTable0),
     compute_interproc_region_lifetime(!.ModuleInfo, RptaInfoTable,
         ExecPathTable, LRBeforeTable0, LRAfterTable0, InputRTable,
-		OutputRTable, ConstantRTable0, BornRTable0, BornRTable1,
-		DeadRTable0, DeadRTable1),
+        OutputRTable, ConstantRTable0, BornRTable0, BornRTable1,
+        DeadRTable0, DeadRTable1),
     ignore_primitive_regions(!.ModuleInfo, RptaInfoTable, 
         BornRTable1, BornRTable, DeadRTable1, DeadRTable,
-		ConstantRTable0, ConstantRTable, LocalRTable0, LocalRTable,
-		LRBeforeTable0, LRBeforeTable, LRAfterTable0, LRAfterTable,
-		VoidVarRegionTable0, VoidVarRegionTable),
+        ConstantRTable0, ConstantRTable, LocalRTable0, LocalRTable,
+        LRBeforeTable0, LRBeforeTable, LRAfterTable0, LRAfterTable,
+        VoidVarRegionTable0, VoidVarRegionTable),
     introduce_region_instructions(!.ModuleInfo, RptaInfoTable,
-		ExecPathTable, LRBeforeTable, LRAfterTable, VoidVarRegionTable,
-		BornRTable, DeadRTable, LocalRTable, AnnotationTable),
+        ExecPathTable, LRBeforeTable, LRAfterTable, VoidVarRegionTable,
+        BornRTable, DeadRTable, LocalRTable, RegionInstructionTable),
 
     record_actual_region_arguments(!.ModuleInfo, RptaInfoTable,
-		ConstantRTable, DeadRTable, BornRTable,
-		ActualRegionArgumentTable),
+        ConstantRTable, DeadRTable, BornRTable,
+        ActualRegionArgumentTable),
 
-	% The region analysis treats region variables as if they are
-	% imperative-style updatable variables. They may also have scopes
-	% which are not valid in Mercury. In order for Mercury code to
-	% manipulate regions we need to map these "region variables" on to
-	% Mercury variables. 
-	% The calls below derive the necessary mapping to resolve the problem.
+    % The region analysis treats region variables as if they are
+    % imperative-style updatable variables. They may also have scopes
+    % which are not valid in Mercury. In order for Mercury code to
+    % manipulate regions we need to map these "region variables" on to
+    % Mercury variables. 
+    % The calls below derive the necessary mapping to resolve the problem.
     compute_resurrection_paths(ExecPathTable, LRBeforeTable, LRAfterTable, 
-		BornRTable, LocalRTable, CreatedBeforeTable,
-		ResurrectionPathTable0),
-	collect_join_points(ResurrectionPathTable0, ExecPathTable,
-		JoinPointTable),
-	collect_paths_containing_join_points(ExecPathTable, JoinPointTable,
-		ResurrectionPathTable0, ResurrectionPathTable),
+        BornRTable, LocalRTable, CreatedBeforeTable,
+        ResurrectionPathTable0),
+    collect_join_points(ResurrectionPathTable0, ExecPathTable,
+        JoinPointTable),
+    collect_paths_containing_join_points(ExecPathTable, JoinPointTable,
+        ResurrectionPathTable0, ResurrectionPathTable),
     collect_region_resurrection_renaming(CreatedBeforeTable, LocalRTable,
-		RptaInfoTable, ResurrectionPathTable, ResurrectionRenameTable),
+        RptaInfoTable, ResurrectionPathTable, ResurrectionRenameTable),
     collect_renaming_and_annotation(ResurrectionRenameTable, JoinPointTable,
-		LRBeforeTable, BornRTable, RptaInfoTable, ResurrectionPathTable,
-		ExecPathTable, ResurRenamingAnnoTable, ResurRenamingTable),
-	collect_non_local_and_in_cond_regions(!.ModuleInfo, RptaInfoTable,
-		LRBeforeTable, LRAfterTable, ResurRenamingTable,
-		ResurRenamingAnnoTable, LocalRegionsTable, InCondRegionsTable),
-	collect_ite_renamed_regions(LocalRegionsTable, InCondRegionsTable,
-		RenamedRegionsTable),
-	collect_ite_renaming(!.ModuleInfo, RptaInfoTable, RenamedRegionsTable,
-		IteRenamingTable),
-	collect_ite_annotation(RenamedRegionsTable, ExecPathTable, 
-		RptaInfoTable, IteRenamingTable, IteRenamingAnnoTable),
-
-	region_transform(RptaInfoTable, ConstantRTable, DeadRTable, BornRTable,
-		ActualRegionArgumentTable, ResurRenamingTable, IteRenamingTable,
-		AnnotationTable, ResurRenamingAnnoTable, IteRenamingAnnoTable,
-		map.init, _NameToVarTable, !ModuleInfo).
+        LRBeforeTable, BornRTable, RptaInfoTable, ResurrectionPathTable,
+        ExecPathTable, ResurRenamingAnnoTable, ResurRenamingTable),
+    collect_non_local_and_in_cond_regions(!.ModuleInfo, RptaInfoTable,
+        LRBeforeTable, LRAfterTable, ResurRenamingTable,
+        ResurRenamingAnnoTable, LocalRegionsTable, InCondRegionsTable),
+    collect_ite_renamed_regions(LocalRegionsTable, InCondRegionsTable,
+        RenamedRegionsTable),
+    collect_ite_renaming(!.ModuleInfo, RptaInfoTable, RenamedRegionsTable,
+        IteRenamingTable),
+    collect_ite_annotation(RenamedRegionsTable, ExecPathTable, 
+        RptaInfoTable, IteRenamingTable, IteRenamingAnnoTable),
+
+    region_transform(RptaInfoTable, ConstantRTable, DeadRTable, BornRTable,
+        ActualRegionArgumentTable, ResurRenamingTable, IteRenamingTable,
+        RegionInstructionTable, ResurRenamingAnnoTable,
+        IteRenamingAnnoTable, map.init, _NameToVarTable, !ModuleInfo).
 
 %-----------------------------------------------------------------------------%
 :- end_module transform_hlds.rbmm.
Index: rbmm.region_instruction.m
===================================================================
RCS file:
/home/mercury/mercury1/repository/mercury/compiler/rbmm.region_instruction.m,v
retrieving revision 1.2
diff -u -u -r1.2 rbmm.region_instruction.m
--- rbmm.region_instruction.m	8 Jun 2007 06:45:11 -0000	1.2
+++ rbmm.region_instruction.m	19 Jul 2007 05:56:03 -0000
@@ -28,19 +28,51 @@
 :- import_module map.
 :- import_module string.
 
-:- type annotation_table == map(pred_proc_id, annotation_proc).
+:- type region_instruction_table == map(pred_proc_id, region_instruction_proc).
 
-:- type annotation_proc == map(program_point, before_after).
-:- type before_after ---> before_after(list(string), list(string)).
+:- type region_instruction_proc == map(program_point, insts_before_after).
+
+:- type insts_before_after
+
+    --->    insts_before_after(
+                insts_before    :: list(region_instruction),
+                                % Region instructions before a program point.
+                                
+                insts_after     :: list(region_instruction)
+                                % Region instructions after a program point.
+            ).
+
+:- type region_instruction
+
+    --->    create_region(
+                % Region name.
+                string
+            )
+
+    ;       remove_region(
+                % Region name.
+                string
+            )
+
+    ;       rename_region(
+                % Old region name.
+                string,
+                
+                % New region name.
+                string
+            ).
+
+:- type region_instruction_type
+
+    --->    create_region_inst
+    ;       remove_region_inst
+    ;       renaming_region_inst.
 
-    % Currently the region instructions are strings, which are attached to
-    % either before or after a program point.
-    % 
 :- pred introduce_region_instructions(module_info::in, rpta_info_table::in,
     execution_path_table::in, proc_pp_region_set_table::in,
     proc_pp_region_set_table::in, proc_pp_region_set_table::in,
     proc_region_set_table::in, proc_region_set_table::in,
-    proc_region_set_table::in, annotation_table::out) is det.
+    proc_region_set_table::in, region_instruction_table::out) is det.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -66,65 +98,64 @@
 
 introduce_region_instructions(ModuleInfo, RptaInfoTable, ExecPathTable,
         LRBeforeTable, LRAfterTable, VoidVarRegionTable, BornRTable,
-        DeadRTable, LocalRTable, AnnotationTable) :-
+        DeadRTable, LocalRTable, RegionInstructionTable) :-
     module_info_predids(PredIds, ModuleInfo, _),
-	map.init(AnnotationTable0),
-	list.foldl(introduce_region_instructions_pred(ModuleInfo,
+    map.init(RegionInstructionTable0),
+    list.foldl(introduce_region_instructions_pred(ModuleInfo,
         RptaInfoTable, ExecPathTable, LRBeforeTable, LRAfterTable,
         VoidVarRegionTable, BornRTable, DeadRTable, LocalRTable), PredIds,
-        AnnotationTable0, AnnotationTable).
+        RegionInstructionTable0, RegionInstructionTable).
 
 :- pred introduce_region_instructions_pred(module_info::in,
     rpta_info_table::in, execution_path_table::in,
     proc_pp_region_set_table::in, proc_pp_region_set_table::in,
     proc_pp_region_set_table::in, proc_region_set_table::in,
     proc_region_set_table::in, proc_region_set_table::in, pred_id::in, 
-    annotation_table::in, annotation_table::out) is det.
+    region_instruction_table::in, region_instruction_table::out) is det.
 
 introduce_region_instructions_pred(ModuleInfo, RptaInfoTable, ExecPathTable,
         LRBeforeTable, LRAfterTable, VoidVarRegionTable, BornRTable,
-        DeadRTable, LocalRTable, PredId, !AnnotationTable) :-
-	module_info_pred_info(ModuleInfo, PredId, PredInfo),
-	pred_info_non_imported_procids(PredInfo) = ProcIds,
-	list.foldl(introduce_region_instructions_proc(ModuleInfo, PredId,
+        DeadRTable, LocalRTable, PredId, !RegionInstructionTable) :-
+    module_info_pred_info(ModuleInfo, PredId, PredInfo),
+    pred_info_non_imported_procids(PredInfo) = ProcIds,
+    list.foldl(introduce_region_instructions_proc(ModuleInfo, PredId,
         RptaInfoTable, ExecPathTable, LRBeforeTable, LRAfterTable,
         VoidVarRegionTable, BornRTable, DeadRTable, LocalRTable),
-        ProcIds, !AnnotationTable).
+        ProcIds, !RegionInstructionTable).
 
 :- pred introduce_region_instructions_proc(module_info::in, pred_id::in,
     rpta_info_table::in, execution_path_table::in,
     proc_pp_region_set_table::in, proc_pp_region_set_table::in,
     proc_pp_region_set_table::in, proc_region_set_table::in,
     proc_region_set_table::in, proc_region_set_table::in, proc_id::in, 
-    annotation_table::in, annotation_table::out) is det.
+    region_instruction_table::in, region_instruction_table::out) is det.
 
 introduce_region_instructions_proc(ModuleInfo, PredId, RptaInfoTable,
         ExecPathTable, LRBeforeTable, LRAfterTable, VoidVarRegionTable,
-        BornRTable, DeadRTable, LocalRTable, ProcId, !AnnotationTable) :-
-	PPId = proc(PredId, ProcId),
-	( if
-		some_are_special_preds([PPId], ModuleInfo)
-	  then
-		true
-	  else
-		module_info_proc_info(ModuleInfo, PPId, ProcInfo),
-		map.lookup(RptaInfoTable, PPId, RptaInfo),
-		map.lookup(BornRTable, PPId, BornR),
-		map.lookup(DeadRTable, PPId, DeadR),
-		map.lookup(LocalRTable, PPId, LocalR),
-		map.lookup(LRBeforeTable, PPId, ProcLRBefore),
-		map.lookup(LRAfterTable, PPId, ProcLRAfter),
-		map.lookup(VoidVarRegionTable, PPId, ProcVoidVarRegion),
-		map.lookup(ExecPathTable, PPId, ExecPaths), 
-		introduce_region_instructions_exec_paths(ExecPaths, RptaInfo,
-            BornR, DeadR, LocalR,
-            ProcLRBefore, ProcLRAfter, ProcVoidVarRegion,
-            BornRTable, DeadRTable, ModuleInfo, ProcInfo,
-            map.init, AnnotationProc),
-		svmap.set(PPId, AnnotationProc, !AnnotationTable)
-	).
+        BornRTable, DeadRTable, LocalRTable, ProcId,
+        !RegionInstructionTable) :-
+    PPId = proc(PredId, ProcId),
+    ( if    some_are_special_preds([PPId], ModuleInfo)
+      then  true
+      else
+            module_info_proc_info(ModuleInfo, PPId, ProcInfo),
+            map.lookup(RptaInfoTable, PPId, RptaInfo),
+            map.lookup(BornRTable, PPId, BornR),
+            map.lookup(DeadRTable, PPId, DeadR),
+            map.lookup(LocalRTable, PPId, LocalR),
+            map.lookup(LRBeforeTable, PPId, ProcLRBefore),
+            map.lookup(LRAfterTable, PPId, ProcLRAfter),
+            map.lookup(VoidVarRegionTable, PPId, ProcVoidVarRegion),
+            map.lookup(ExecPathTable, PPId, ExecPaths), 
+            introduce_region_instructions_exec_paths(ExecPaths, RptaInfo,
+                BornR, DeadR, LocalR,
+                ProcLRBefore, ProcLRAfter, ProcVoidVarRegion,
+                BornRTable, DeadRTable, ModuleInfo, ProcInfo,
+                map.init, RegionInstructionProc),
+            svmap.set(PPId, RegionInstructionProc, !RegionInstructionTable)
+    ).
 
-	% Follow each execution path of a procedure and introduce 
+    % Follow each execution path of a procedure and introduce 
     % region instructions at each program point.
     %
 :- pred introduce_region_instructions_exec_paths(list(execution_path)::in,
@@ -132,70 +163,70 @@
     pp_region_set_table::in, pp_region_set_table::in, 
     pp_region_set_table::in, proc_region_set_table::in, 
     proc_region_set_table::in, module_info::in, proc_info::in, 
-    annotation_proc::in, annotation_proc::out) is det.
+    region_instruction_proc::in, region_instruction_proc::out) is det.
 
 introduce_region_instructions_exec_paths([], _, _, _, _, _, _, _, _, _, _, _,
-        !AnnotationProc).
+        !RegionInstructionProc).
 introduce_region_instructions_exec_paths([ExecPath|ExecPaths], RptaInfo,
         BornR, DeadR, LocalR, ProcLRBefore, ProcLRAfter, ProcVoidVarRegion,
-        BornRTable, DeadRTable, ModuleInfo, ProcInfo, !AnnotationProc) :-
-	introduce_region_instructions_exec_path(ExecPath, RptaInfo, BornR,
+        BornRTable, DeadRTable, ModuleInfo, ProcInfo,
+        !RegionInstructionProc) :-
+    introduce_region_instructions_exec_path(ExecPath, RptaInfo, BornR,
         DeadR, LocalR, ProcLRBefore, ProcLRAfter, ProcVoidVarRegion,
-        BornRTable, DeadRTable, ModuleInfo, ProcInfo, !AnnotationProc),
-	introduce_region_instructions_exec_paths(ExecPaths, RptaInfo, BornR,
+        BornRTable, DeadRTable, ModuleInfo, ProcInfo, !RegionInstructionProc),
+    introduce_region_instructions_exec_paths(ExecPaths, RptaInfo, BornR,
         DeadR, LocalR, ProcLRBefore, ProcLRAfter, ProcVoidVarRegion,
-        BornRTable, DeadRTable, ModuleInfo, ProcInfo, !AnnotationProc).
+        BornRTable, DeadRTable, ModuleInfo, ProcInfo, !RegionInstructionProc).
 
 :- pred introduce_region_instructions_exec_path(execution_path::in,
     rpta_info::in, set(rptg_node)::in, set(rptg_node)::in, set(rptg_node)::in,
     pp_region_set_table::in, pp_region_set_table::in,
     pp_region_set_table::in, proc_region_set_table::in,
     proc_region_set_table::in, module_info::in, proc_info::in,
-    annotation_proc::in, annotation_proc::out) is det.
+    region_instruction_proc::in, region_instruction_proc::out) is det.
 introduce_region_instructions_exec_path([], _, _, _, _, _, _, _, _, _, _, _,
-        !AnnotationProc).
+        !RegionInstructionProc).
 introduce_region_instructions_exec_path([ProgPoint - Goal | ProgPoint_Goals],
         RptaInfo, BornR, DeadR, LocalR, ProcLRBefore, ProcLRAfter,
         ProcVoidVarRegion, BornRTable, DeadRTable, ModuleInfo, ProcInfo,
-        !AnnotationProc) :-
-	map.lookup(ProcLRBefore, ProgPoint, LRBefore),
-	map.lookup(ProcLRAfter, ProgPoint, LRAfter),
-	map.lookup(ProcVoidVarRegion, ProgPoint, VoidVarRegions),
+        !RegionInstructionProc) :-
+    map.lookup(ProcLRBefore, ProgPoint, LRBefore),
+    map.lookup(ProcLRAfter, ProgPoint, LRAfter),
+    map.lookup(ProcVoidVarRegion, ProgPoint, VoidVarRegions),
 
     % Because void variables at this program point are considered dead
     % right after they get bound, the regions that are reached from them
     % are also candidates to be removed. They will be destroyed after this
     % program point if they are not live after the program point and they
     % are either in DeadR or LocalR or BornR.
-	set.difference(VoidVarRegions, LRAfter, DeadVoidVarRegions0),
-	set.union(LocalR, BornR, Local_Born),
-	set.union(Local_Born, DeadR, Local_Born_Dead),
-	set.intersect(Local_Born_Dead, DeadVoidVarRegions0, DeadVoidVarRegions),
-	RptaInfo = rpta_info(Graph_p, _),
-	set.fold(record_instruction_after_prog_point(ProgPoint, Graph_p,
-        "Tn", "remove"), DeadVoidVarRegions, !AnnotationProc),
+    set.difference(VoidVarRegions, LRAfter, DeadVoidVarRegions0),
+    set.union(LocalR, BornR, Local_Born),
+    set.union(Local_Born, DeadR, Local_Born_Dead),
+    set.intersect(Local_Born_Dead, DeadVoidVarRegions0, DeadVoidVarRegions),
+    RptaInfo = rpta_info(CallerGraph, _),
+    set.fold(record_instruction_after_prog_point(remove_region_inst, ProgPoint,
+        CallerGraph), DeadVoidVarRegions, !RegionInstructionProc),
 
     set.difference(LRBefore, LRAfter, ToBeRemoved),
     set.intersect(ToBeRemoved, Local_Born_Dead, ToBeRemovedAndAllowed),
-	( if 
-		Goal = hlds_goal(switch(_, _, _), _)
-	  then
-        % This is a switch, i.e. unification, only rule 4 applied.
-		transformation_rule_4_2(ProgPoint, ToBeRemovedAndAllowed,
-            RptaInfo, !AnnotationProc)
-	  else 
-		Goal = hlds_goal(Expr, _),
-        set.difference(LRAfter, LRBefore, ToBeCreated),
-        set.intersect(ToBeCreated, Local_Born, ToBeCreatedAndAllowed),
-        transformation_rule_1(Expr, ProgPoint, ToBeCreatedAndAllowed,
-            RptaInfo, BornRTable, !AnnotationProc),
-        transformation_rule_2(Expr, ProgPoint, ToBeCreatedAndAllowed,
-            RptaInfo, ModuleInfo, ProcInfo, !AnnotationProc),
-        transformation_rule_3(Expr, ProgPoint, ToBeRemovedAndAllowed,
-            RptaInfo, DeadRTable, !AnnotationProc),
-        transformation_rule_4(Expr, ProgPoint, ToBeRemovedAndAllowed,
-            RptaInfo, !AnnotationProc)
-	),
+    ( if    Goal = hlds_goal(switch(_, _, _), _)
+      then
+            % This is a switch, i.e. unification, only rule 4 applied.
+            transformation_rule_4_2(ProgPoint, ToBeRemovedAndAllowed,
+                RptaInfo, !RegionInstructionProc)
+      else 
+            Goal = hlds_goal(Expr, _),
+            set.difference(LRAfter, LRBefore, ToBeCreated),
+            set.intersect(ToBeCreated, Local_Born, ToBeCreatedAndAllowed),
+            transformation_rule_1(Expr, ProgPoint, ToBeCreatedAndAllowed,
+                RptaInfo, BornRTable, !RegionInstructionProc),
+            transformation_rule_2(Expr, ProgPoint, ToBeCreatedAndAllowed,
+                RptaInfo, ModuleInfo, ProcInfo, !RegionInstructionProc),
+            transformation_rule_3(Expr, ProgPoint, ToBeRemovedAndAllowed,
+                RptaInfo, DeadRTable, !RegionInstructionProc),
+            transformation_rule_4(Expr, ProgPoint, ToBeRemovedAndAllowed,
+                RptaInfo, !RegionInstructionProc)
+    ),
 
     (
         ProgPoint_Goals = [NextProgPoint - _ | _],
@@ -208,294 +239,289 @@
         set.difference(LRAfter, LRBeforeNext, ToBeRemovedBeforeNext),
         set.intersect(Local_Born_Dead, ToBeRemovedBeforeNext, 
             ToBeRemovedBeforeNextAndAllowed),
-        set.fold(record_instruction_before_prog_point(NextProgPoint, Graph_p,
-                    "T5", "remove"),
-            ToBeRemovedBeforeNextAndAllowed, !AnnotationProc),
+        set.fold(record_instruction_before_prog_point(remove_region_inst,
+            NextProgPoint, CallerGraph), ToBeRemovedBeforeNextAndAllowed,
+            !RegionInstructionProc),
 
         introduce_region_instructions_exec_path(ProgPoint_Goals, RptaInfo,
             BornR, DeadR, LocalR,
             ProcLRBefore, ProcLRAfter, ProcVoidVarRegion,
-            BornRTable, DeadRTable, ModuleInfo, ProcInfo, !AnnotationProc)
+            BornRTable, DeadRTable, ModuleInfo, ProcInfo,
+            !RegionInstructionProc)
     ;
         % This is the last program point, we finish.
-        ProgPoint_Goals = [],
-        true
+        ProgPoint_Goals = []
     ).
-	
-	% Rule 1: if an output region of q is not live, not created by q, 
-	% and p is allowed to create it, it is created before the call to q.
-	%
-	% There are two cases: either q is defined in this module or q is
+    
+    % Rule 1: if an output region of q is not live, not created by q, 
+    % and p is allowed to create it, it is created before the call to q.
+    %
+    % There are two cases: either q is defined in this module or q is
     % imported.
-	% The former is dealt with as per the rule.
-	% The latter: for now, with the assumption that all source code is in
+    % The former is dealt with as per the rule.
+    % The latter: for now, with the assumption that all source code is in
     % only one module, imported preds will only be ones from 
     % Mercury's library. We do not intent to deal with the library's code
     % now therefore we have to assume here that the caller will always
     % *CREATE* the OUTPUT REGION for those procedures.
-	%
+    %
 :- pred transformation_rule_1(hlds_goal_expr::in, program_point::in,
     region_set::in, rpta_info::in, proc_region_set_table::in,
-    annotation_proc::in, annotation_proc::out) is det.
+    region_instruction_proc::in, region_instruction_proc::out) is det.
 
 transformation_rule_1(Expr, ProgPoint, ToBeCreatedAndAllowed, CallerRptaInfo,
-        BornRTable, !AnnotationProc) :-
-    (
-        Expr = plain_call(CalleePredId, CalleeProcId, _, _, _, _)
-    -> 
+        BornRTable, !RegionInstructionProc) :-
+    ( Expr = plain_call(CalleePredId, CalleeProcId, _, _, _, _) -> 
         CalleePPId = proc(CalleePredId, CalleeProcId),
         CallerRptaInfo = rpta_info(CallerGraph, AlphaMapping),
         ( if
-            % Currently we do not collect BornR for non-defined-in-module 
-            % procedure, so if we cannot find one here then q is an
-            % imported.
-            map.search(BornRTable, CalleePPId, _)
-        then
-            map.lookup(AlphaMapping, ProgPoint, AlphaAtProgPoint),
-            map.lookup(BornRTable, CalleePPId, CalleeBornR),
-            map.foldl(process_mapping_rule_1(ProgPoint, ToBeCreatedAndAllowed, 
-                CalleeBornR, CallerGraph), AlphaAtProgPoint, !AnnotationProc)
-        else
-            % q is from an imported module, therefore we consider  
-            % BornR of q empty, so just create whatever regions becoming
-            % live provided that they are in BornR or LocalR, i.e., p is
-            % allowed to create them.
-            set.fold(record_instruction_before_prog_point(ProgPoint,
-                CallerGraph, "T1", "create"), ToBeCreatedAndAllowed,
-                !AnnotationProc)
+                % Currently we do not collect BornR for non-defined-in-module 
+                % procedure, so if we cannot find one here then q is an
+                % imported.
+                map.search(BornRTable, CalleePPId, _)
+          then
+                map.lookup(AlphaMapping, ProgPoint, AlphaAtProgPoint),
+                map.lookup(BornRTable, CalleePPId, CalleeBornR),
+                map.foldl(process_mapping_rule_1(ProgPoint,
+                    ToBeCreatedAndAllowed, CalleeBornR, CallerGraph),
+                    AlphaAtProgPoint, !RegionInstructionProc)
+          else
+                % q is from an imported module, therefore we consider  BornR of
+                % q empty, so just create whatever regions becoming live
+                % provided that they are in BornR or LocalR, i.e., p is allowed
+                % to create them.
+                set.fold(record_instruction_before_prog_point(
+                    create_region_inst, ProgPoint, CallerGraph),
+                    ToBeCreatedAndAllowed, !RegionInstructionProc)
         )
     ;
-        (Expr = conj(_, [])
-        ;Expr = disj([])
-        ;Expr = unify(_, _, _, _, _))
-    -> 
-        true
+        ( Expr = conj(_, [])
+        ; Expr = disj([])
+        ; Expr = unify(_, _, _, _, _)
+        ) ->    true
     ;
-        unexpected(this_file,
-            "transformation_rule_1: found non-atomic goal")
+        unexpected(this_file, "transformation_rule_1: found non-atomic goal")
     ).
 
 :- pred process_mapping_rule_1(program_point::in, region_set::in,
     region_set::in, rpt_graph::in, rptg_node::in, rptg_node::in,
-    annotation_proc::in, annotation_proc::out) is det.
+    region_instruction_proc::in, region_instruction_proc::out) is det.
 
 process_mapping_rule_1(ProgPoint, ToBeCreatedAndAllowed, CalleeBornR,
-        CallerGraph, SourceRegion, TargetRegion, !AnnotationProc) :-
-	( if
-		(
-			set.contains(ToBeCreatedAndAllowed, TargetRegion),
-			not set.contains(CalleeBornR, SourceRegion)
-		)
-	  then
-		record_instruction_before_prog_point(ProgPoint, CallerGraph,
-            "T1", "create", TargetRegion, !AnnotationProc)
-	  else
-		true
-	).
+        CallerGraph, SourceRegion, TargetRegion, !RegionInstructionProc) :-
+    ( if    ( set.contains(ToBeCreatedAndAllowed, TargetRegion),
+              not set.contains(CalleeBornR, SourceRegion)
+            )
+      then  record_instruction_before_prog_point(create_region_inst, ProgPoint,
+                CallerGraph, TargetRegion, !RegionInstructionProc)
+      else  true
+    ).
 
-	% Transformation rule 2: if a region reachable from the left variable
+    % Transformation rule 2: if a region reachable from the left variable
     % of a construction is not live before the construction but it is live
     % after and is a local region or in a BornR set, then the region is
     % created before the unification.
-	% 
+    % 
 :- pred transformation_rule_2(hlds_goal_expr::in, program_point::in,
     region_set::in, rpta_info::in, module_info::in, proc_info::in, 
-    annotation_proc::in, annotation_proc::out) is det.
+    region_instruction_proc::in, region_instruction_proc::out) is det.
 
 transformation_rule_2(Expr, ProgPoint, ToBeCreatedAndAllowed, RptaInfo,
-        ModuleInfo, ProcInfo, !AnnotationProc) :-
-    (
-        Expr = unify(X, _, _, construct(_, _, _, _, _, _, _), _)
-    ->
+        ModuleInfo, ProcInfo, !RegionInstructionProc) :-
+    ( Expr = unify(X, _, _, construct(_, _, _, _, _, _, _), _) ->
         RptaInfo = rpta_info(Graph, _AlphaMapping),
-        % need to be regions reachable from X
+        % Need to be regions reachable from X.
         reach_from_a_variable(Graph, ModuleInfo, ProcInfo, X,
             set.init, Reach_X),
 
         set.intersect(Reach_X, ToBeCreatedAndAllowed,
             ToBeCreatedAllowedAndReached),
-        set.fold(record_instruction_before_prog_point(ProgPoint, Graph,
-                    "T2", "create"),
-            ToBeCreatedAllowedAndReached, !AnnotationProc)
+        set.fold(record_instruction_before_prog_point(create_region_inst,
+            ProgPoint, Graph), ToBeCreatedAllowedAndReached,
+            !RegionInstructionProc)
     ;
-        (Expr = unify(_, _, _, deconstruct(_, _, _, _, _, _), _)
-        ;Expr = unify(_, _, _, assign(_, _), _)
-        ;Expr = unify(_, _, _, simple_test(_, _), _)
-        ;Expr = unify(_, _, _, complicated_unify(_, _, _), _)
-        ;Expr = plain_call(_, _, _, _, _, _)
-        ;Expr = conj(_, [])
-        ;Expr = disj([]))
-    ->    
-        true
+        ( Expr = unify(_, _, _, deconstruct(_, _, _, _, _, _), _)
+        ; Expr = unify(_, _, _, assign(_, _), _)
+        ; Expr = unify(_, _, _, simple_test(_, _), _)
+        ; Expr = unify(_, _, _, complicated_unify(_, _, _), _)
+        ; Expr = plain_call(_, _, _, _, _, _)
+        ; Expr = conj(_, [])
+        ; Expr = disj([])
+        ) ->    true
     ;
-        unexpected(this_file,
-            "transformation_rule_2: non-atomic goal found")
+        unexpected(this_file, "transformation_rule_2: non-atomic goal found")
     ).
 
-	% Transformation rule 3: if a region is live before q but it is not
+    % Transformation rule 3: if a region is live before q but it is not
     % live after q and it is not removed by q, the caller will remove it
     % after calling q.
-	% 
-	% There are two cases: either q is defined in this module or q is
+    % 
+    % There are two cases: either q is defined in this module or q is
     % imported.
-	% The former is straightforward because we have the analysis information
+    % The former is straightforward because we have the analysis information
     % for q.
-	% The latter for now, with the assumption that all source code is in
+    % The latter for now, with the assumption that all source code is in
     % only one module, imported preds will only be ones from
     % Mercury's library. We do not intent to deal with the library's code
     % now therefore we have to assume here that the caller will always
     % REMOVE the REGIONs for those procedures.
-	% 
+    % 
 :- pred transformation_rule_3(hlds_goal_expr::in, program_point::in,
     region_set::in, rpta_info::in, proc_region_set_table::in,
-    annotation_proc::in, annotation_proc::out) is det.
+    region_instruction_proc::in, region_instruction_proc::out) is det.
 
 transformation_rule_3(Expr, ProgPoint, ToBeRemovedAndAllowed, CallerRptaInfo,
-        DeadRTable, !AnnotationProc) :-
-    (
-        Expr =  plain_call(CalleePredId, CalleeProcId, _, _, _, _)
-    ->
+        DeadRTable, !RegionInstructionProc) :-
+    ( Expr =  plain_call(CalleePredId, CalleeProcId, _, _, _, _) ->
         CalleePPId = proc(CalleePredId, CalleeProcId),
         CallerRptaInfo = rpta_info(CallerGraph, AlphaMapping),
-        ( if
-            map.search(DeadRTable, CalleePPId, _)
+        ( if    map.search(DeadRTable, CalleePPId, _)
           then
-            map.lookup(AlphaMapping, ProgPoint, AlphaAtProgPoint),
+                map.lookup(AlphaMapping, ProgPoint, AlphaAtProgPoint),
 
-            map.lookup(DeadRTable, CalleePPId, CalleeDeadR),
-            map.foldl(process_mapping_rule_3(ProgPoint,
-                        ToBeRemovedAndAllowed, CalleeDeadR, CallerGraph),
-                AlphaAtProgPoint, !AnnotationProc)
+                map.lookup(DeadRTable, CalleePPId, CalleeDeadR),
+                map.foldl(process_mapping_rule_3(ProgPoint,
+                    ToBeRemovedAndAllowed, CalleeDeadR, CallerGraph),
+                    AlphaAtProgPoint, !RegionInstructionProc)
           else
-            % q is from an imported module. So just remove whatever regions
-            % become dead provided that p is allowed to remove those regions.
-            set.fold(record_instruction_after_prog_point(ProgPoint,
-                        CallerGraph, "T3", "remove"),
-                ToBeRemovedAndAllowed, !AnnotationProc)
+                % q is from an imported module. So just remove whatever regions
+                % become dead provided that p is allowed to remove those
+                % regions.
+                set.fold(record_instruction_after_prog_point(
+                    remove_region_inst, ProgPoint, CallerGraph),
+                    ToBeRemovedAndAllowed, !RegionInstructionProc)
         )
     ;
-        (Expr = unify(_, _, _, _, _)
-        ;Expr = conj(_, [])
-        ;Expr = disj([]))
-    ->
-        true
+        ( Expr = unify(_, _, _, _, _)
+        ; Expr = conj(_, [])
+        ; Expr = disj([])
+        ) ->    true
     ;
-        unexpected(this_file,
-            "transformation_rule_3: non-atomic goal found")
+        unexpected(this_file, "transformation_rule_3: non-atomic goal found")
     ).
 
 :- pred process_mapping_rule_3(program_point::in, region_set::in, 
     region_set::in, rpt_graph::in, rptg_node::in, rptg_node::in,
-    annotation_proc::in, annotation_proc::out) is det.
+    region_instruction_proc::in, region_instruction_proc::out) is det.
 
 process_mapping_rule_3(ProgPoint, ToBeRemovedAndAllowed, CalleeDeadR,
-        CallerGraph, SourceRegion, TargetRegion, !AnnotationProc) :-
- 	( if
-		(
-            set.contains(ToBeRemovedAndAllowed, TargetRegion),
-            not set.contains(CalleeDeadR, SourceRegion)
-        )
-	  then
-	  	record_instruction_after_prog_point(ProgPoint, CallerGraph,
-            "T3", "remove", TargetRegion, !AnnotationProc)
-	  else
-		true
-	).
-
-	% Transformation rule 4: if a region is live before a unification but 
-	% it is not live after and it is in the dead region set or is a local
-	% region, then it is removed after the unification if the current
+        CallerGraph, SourceRegion, TargetRegion, !RegionInstructionProc) :-
+    ( if    ( set.contains(ToBeRemovedAndAllowed, TargetRegion),
+              not set.contains(CalleeDeadR, SourceRegion)
+            )
+      then  record_instruction_after_prog_point(remove_region_inst,
+                ProgPoint, CallerGraph, TargetRegion, !RegionInstructionProc)
+      else  true
+    ).
+
+    % Transformation rule 4: if a region is live before a unification but 
+    % it is not live after and it is in the dead region set or is a local
+    % region, then it is removed after the unification if the current
     % procedure is allowed to remove it.
     %
 :- pred transformation_rule_4(hlds_goal_expr::in, program_point::in,
-    region_set::in, rpta_info::in, annotation_proc::in, 
-    annotation_proc::out) is det.
+    region_set::in, rpta_info::in, region_instruction_proc::in, 
+    region_instruction_proc::out) is det.
 
 transformation_rule_4(Expr, ProgPoint, ToBeRemovedAndAllowed, RptaInfo,
-        !AnnotationProc) :-
-    (
-        Expr = unify(_, _, _, _, _)
-    ->
+        !RegionInstructionProc) :-
+    ( Expr = unify(_, _, _, _, _) ->
         RptaInfo = rpta_info(Graph, _),
-	  	set.fold(record_instruction_after_prog_point(ProgPoint, Graph,
-            "T4", "remove"), ToBeRemovedAndAllowed, !AnnotationProc)
+        set.fold(record_instruction_after_prog_point(remove_region_inst,
+            ProgPoint, Graph), ToBeRemovedAndAllowed, !RegionInstructionProc)
     ;
-        (Expr = plain_call(_, _, _, _, _, _)
-        ;Expr = conj(_, [])
-        ;Expr = disj([]))
-    ->
-        true
-    ;
-        unexpected(this_file,
-            "transformation_rule_4: non-atomic goal found")
+      ( Expr = plain_call(_, _, _, _, _, _)
+      ; Expr = conj(_, [])
+      ; Expr = disj([])
+      ) ->  true
+    ;   
+        unexpected(this_file, "transformation_rule_4: non-atomic goal found")
     ).
 
-	% This is for the case rule 4 applied for a unification in a switch, 
-	% the unification has been removed by MMC.
-	% We will record the annotations after the program point.
+    % This is for the case rule 4 applied for a unification in a switch, 
+    % the unification has been removed by MMC.
+    % We will record the annotations after the program point.
     %
 :- pred transformation_rule_4_2(program_point::in, region_set::in,
-    rpta_info::in, annotation_proc::in, annotation_proc::out) is det.
+    rpta_info::in, region_instruction_proc::in, region_instruction_proc::out)
+    is det.
 
 transformation_rule_4_2(ProgPoint, ToBeRemovedAndAllowed, RptaInfo,
-        !AnnotationProc) :-
-	RptaInfo = rpta_info(Graph, _),
-    set.fold(record_instruction_after_prog_point(ProgPoint, Graph,
-        "T4", "remove"), ToBeRemovedAndAllowed, !AnnotationProc).
-
-:- pred record_instruction_after_prog_point(program_point::in,
-    rpt_graph::in, string::in, string::in, rptg_node::in,
-    annotation_proc::in, annotation_proc::out) is det.
-
-record_instruction_after_prog_point(ProgPoint, Graph_p, Rule, Action, Region,
-        !AnnotationProc) :-
-	rptg_node_contents(Graph_p, Region, Content),
-	RegionAnno = string.format("%s: %s %s",
-        [s(Rule), s(Action), s(Content^reg_var_name)]),
-    % get After of the pp and add annotation to it
-	( if
-		map.search(!.AnnotationProc, ProgPoint,
-            before_after(Before, After))
-	then
-		( if 
-			list.member(RegionAnno, After)
-		  then
-			true
-		  else
-			svmap.set(ProgPoint,
-                before_after(Before, [RegionAnno | After]), !AnnotationProc)
-		)
-	else
-		svmap.set(ProgPoint, before_after([], [RegionAnno]),
-            !AnnotationProc)
-	).
-
-:- pred record_instruction_before_prog_point(program_point::in,
-    rpt_graph::in, string::in, string::in, rptg_node::in,
-    annotation_proc::in, annotation_proc::out) is det.
-
-record_instruction_before_prog_point(ProgPoint, Graph_p, Rule, Action,
-        Region, !AnnotationProc) :-
-	rptg_node_contents(Graph_p, Region, Content),
-	RegionAnno = string.format("%s: %s %s",
-        [s(Rule), s(Action), s(Content^reg_var_name)]),
-    % get After of the pp and add annotation to it
-	( if
-		map.search(!.AnnotationProc, ProgPoint,
-            before_after(Before, After))
-	then
-		( if 
-			list.member(RegionAnno, Before)
-		  then
-			true
-		  else
-			svmap.set(ProgPoint,
-                before_after([RegionAnno | Before], After), !AnnotationProc)
-		)
-	else
-		svmap.set(ProgPoint, before_after([RegionAnno], []),
-            !AnnotationProc)
-	).
+        !RegionInstructionProc) :-
+    RptaInfo = rpta_info(Graph, _),
+    set.fold(record_instruction_after_prog_point(remove_region_inst, ProgPoint,
+        Graph), ToBeRemovedAndAllowed, !RegionInstructionProc).
+
+:- pred record_instruction_after_prog_point(region_instruction_type::in,
+    program_point::in, rpt_graph::in, rptg_node::in,
+    region_instruction_proc::in, region_instruction_proc::out) is det.
+
+record_instruction_after_prog_point(RegionInstType, ProgPoint, Graph, Region,
+        !RegionInstructionProc) :-
+    RegionName = rptg_lookup_region_name(Graph, Region),
+    make_create_or_remove_instruction(RegionInstType, RegionName,
+        RegionInstruction),
+    % Attach the instruction to after the program point.
+    ( if    map.search(!.RegionInstructionProc, ProgPoint,
+                insts_before_after(InstsBefore, InstsAfter))
+      then
+            ( if    list.member(RegionInstruction, InstsAfter)
+              then  true
+              else  svmap.set(ProgPoint,
+                        insts_before_after(InstsBefore,
+                            [RegionInstruction | InstsAfter]),
+                        !RegionInstructionProc)
+            )
+      else  svmap.set(ProgPoint,
+                insts_before_after([], [RegionInstruction]),
+                !RegionInstructionProc)
+    ).
+
+:- pred record_instruction_before_prog_point(region_instruction_type::in,
+    program_point::in, rpt_graph::in, rptg_node::in,
+    region_instruction_proc::in, region_instruction_proc::out) is det.
+
+record_instruction_before_prog_point(RegionInstType, ProgPoint, Graph, Region,
+        !RegionInstructionProc) :-
+    RegionName = rptg_lookup_region_name(Graph, Region),
+    make_create_or_remove_instruction(RegionInstType, RegionName,
+        RegionInstruction),
+    % Attach the instruction to before the program point.
+    ( if    map.search(!.RegionInstructionProc, ProgPoint,
+                insts_before_after(InstsBefore, InstsAfter))
+      then
+            ( if     list.member(RegionInstruction, InstsBefore)
+              then   true
+              else   svmap.set(ProgPoint,
+                        insts_before_after([RegionInstruction | InstsBefore],
+                            InstsAfter),
+                        !RegionInstructionProc)
+            )
+      else  svmap.set(ProgPoint,
+                    insts_before_after([RegionInstruction], []),
+                    !RegionInstructionProc)
+    ).
+
+:- pred make_create_or_remove_instruction(region_instruction_type::in,
+    string::in, region_instruction::out) is det.
+
+make_create_or_remove_instruction(RegionInstType, RegionName,
+        RegionInstruction) :-
+    (
+        RegionInstType = create_region_inst,
+        RegionInstruction = create_region(RegionName)
+    ;
+        RegionInstType = remove_region_inst,
+        RegionInstruction = remove_region(RegionName)
+    ;
+        RegionInstType = renaming_region_inst,
+        unexpected(this_file, "make_create_or_remove_instruction: "
+            ++ "unexpected region instruction type")
+    ).
+
+%-----------------------------------------------------------------------------%
 
 :- func this_file = string.
 this_file = "rbmm.region_instruction.m".
+
+%-----------------------------------------------------------------------------%
Index: rbmm.region_transformation.m
===================================================================
RCS file:
/home/mercury/mercury1/repository/mercury/compiler/rbmm.region_transformation.m,v
retrieving revision 1.1
diff -u -u -r1.1 rbmm.region_transformation.m
--- rbmm.region_transformation.m	6 Jul 2007 02:35:20 -0000	1.1
+++ rbmm.region_transformation.m	19 Jul 2007 05:56:03 -0000
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% vim: ft=mercury ts=4 sw=4
+% vim: ft=mercury ts=4 sw=4 et
 %-----------------------------------------------------------------------------%
 % Copyright (C) 2007 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
@@ -29,34 +29,34 @@
 :- import_module parse_tree.prog_data.
 :- import_module transform_hlds.rbmm.actual_region_arguments.
 :- import_module transform_hlds.rbmm.points_to_info.
+:- import_module transform_hlds.rbmm.region_instruction.
 :- import_module transform_hlds.rbmm.region_liveness_info.
 :- import_module transform_hlds.rbmm.region_resurrection_renaming.
-:- import_module transform_hlds.rbmm.region_instruction.
 
 :- import_module map.
 :- import_module string.
 %-----------------------------------------------------------------------------%
 
-	% Represent mapping from region name to a program variable that
-	% represents the region.
-	%
+    % Represent mapping from region name to a program variable that
+    % represents the region.
+    %
 :- type name_to_prog_var_table == map(pred_proc_id, name_to_prog_var).
 :- type name_to_prog_var == map(string, prog_var).
 
-	% XXX Besides changing the HLDS, this predicate also returns a mapping
-	% from a region name to a program variable which represents the
-	% region. We will only create a new program variable for a region
-	% name which is not yet in the map. Currently this map is only used
-	% in this transformation. If we do not need the map later on we should
-	% not return it.
-	%
+    % XXX Besides changing the HLDS, this predicate also returns a mapping
+    % from a region name to a program variable which represents the
+    % region. We will only create a new program variable for a region
+    % name which is not yet in the map. Currently this map is only used
+    % in this transformation. If we do not need the map later on we should
+    % not return it.
+    %
 :- pred region_transform(rpta_info_table::in, proc_region_set_table::in,
-	proc_region_set_table::in, proc_region_set_table::in,
-	proc_pp_pair_region_list_table::in,
-	renaming_table::in, renaming_table::in, annotation_table::in,
-	renaming_annotation_table::in, renaming_annotation_table::in,
-	name_to_prog_var_table::in, name_to_prog_var_table::out,
-	module_info::in, module_info::out) is det.
+    proc_region_set_table::in, proc_region_set_table::in,
+    proc_pp_pair_region_list_table::in,
+    renaming_table::in, renaming_table::in, region_instruction_table::in,
+    renaming_annotation_table::in, renaming_annotation_table::in,
+    name_to_prog_var_table::in, name_to_prog_var_table::out,
+    module_info::in, module_info::out) is det.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -77,6 +77,7 @@
 :- import_module libs.compiler_util.
 :- import_module mdbcomp.prim_data.
 :- import_module parse_tree.prog_mode.
+:- import_module parse_tree.prog_type.
 :- import_module transform_hlds.rbmm.points_to_graph.
 :- import_module transform_hlds.smm_common.
 
@@ -92,872 +93,854 @@
 %-----------------------------------------------------------------------------%
 
 region_transform(RptaInfoTable, ConstantRTable, DeadRTable, BornRTable,
-		ActualRegionArgTable, ResurRenamingTable, IteRenamingTable,
-		AnnotationTable, ResurRenamingAnnoTable, IteRenamingAnnoTable,
-		!NameToVarTable, !ModuleInfo) :-
-	map.foldl2(annotate_pred(DeadRTable, BornRTable), ConstantRTable, [],
-		PredIds, !ModuleInfo),
-	list.foldl2(region_transform_pred(RptaInfoTable,
-		ConstantRTable, DeadRTable, BornRTable, ActualRegionArgTable,
-		ResurRenamingTable, IteRenamingTable,
-		AnnotationTable, ResurRenamingAnnoTable, IteRenamingAnnoTable),
-		PredIds, !NameToVarTable, !ModuleInfo),
-	% We can only do the followings when all the procedures have been
-	% annotated with region information and recorded. This is necessary
-	% because recompute_instmap_delta_proc and repuritycheck_proc need to
-	% look up information about the (annotated) called procedures.
-	%
+        ActualRegionArgTable, ResurRenamingTable, IteRenamingTable,
+        RegionInstructionTable, ResurRenamingAnnoTable, IteRenamingAnnoTable,
+        !NameToVarTable, !ModuleInfo) :-
+    map.foldl2(annotate_pred(DeadRTable, BornRTable), ConstantRTable, [],
+        PredIds, !ModuleInfo),
+    list.foldl2(region_transform_pred(RptaInfoTable,
+        ConstantRTable, DeadRTable, BornRTable, ActualRegionArgTable,
+        ResurRenamingTable, IteRenamingTable,
+        RegionInstructionTable, ResurRenamingAnnoTable, IteRenamingAnnoTable),
+        PredIds, !NameToVarTable, !ModuleInfo),
+    % We can only do the followings when all the procedures have been
+    % annotated with region information and recorded. This is necessary
+    % because recompute_instmap_delta_proc and repuritycheck_proc need to
+    % look up information about the (annotated) called procedures.
+    %
     list.foldl(update_instmap_delta_pred, PredIds, !ModuleInfo),
-	list.foldl(recheck_purity_pred, PredIds, !ModuleInfo).
+    list.foldl(recheck_purity_pred, PredIds, !ModuleInfo).
 
-	% This predicate updates pred_info structure. The following information
-	% is updated:
-	% 1. Original arity: orig_arity, which is updated with the old value +
-	% the number of region arguments.
-	% 2. Argument types: arg_types, updated with region type for region
-	% arguments.
-	%
+    % This predicate updates pred_info structure. The following information
+    % is updated:
+    % 1. Original arity: orig_arity, which is updated with the old value +
+    % the number of region arguments.
+    % 2. Argument types: arg_types, updated with region type for region
+    % arguments.
+    %
 :- pred annotate_pred(proc_region_set_table::in, proc_region_set_table::in,
-	pred_proc_id::in, region_set::in, list(pred_id)::in, list(pred_id)::out,
-	module_info::in, module_info::out) is det.
+    pred_proc_id::in, region_set::in, list(pred_id)::in, list(pred_id)::out,
+    module_info::in, module_info::out) is det.
 
 annotate_pred(DeadRTable, BornRTable, PPId, ConstantR, !Processed,
-		!ModuleInfo) :-
-	PPId = proc(PredId, _),
-	( if	list.member(PredId, !.Processed)
-	  then	true
-	  else  
-			some [!PredInfo] (
-				module_info_pred_info(!.ModuleInfo, PredId,
-					!:PredInfo),
-				map.lookup(DeadRTable, PPId, DeadR),
-				map.lookup(BornRTable, PPId, BornR),
-				NumberOfRegArgs = set.count(DeadR) +
-					set.count(BornR) + set.count(ConstantR),
-				Arity = pred_info_orig_arity(!.PredInfo),
-				pred_info_set_orig_arity(
-					Arity + NumberOfRegArgs, !PredInfo),
-
-				list.duplicate(NumberOfRegArgs,
-					make_region_type, RegionTypes),
-				pred_info_get_arg_types(!.PredInfo, TypeVarSet,
-					ExistQuantTVars, ArgTypes0),
-				PredOrFunc =
-					pred_info_is_pred_or_func(!.PredInfo),
-				(
-					PredOrFunc = pf_predicate,
-					ArgTypes = ArgTypes0 ++ RegionTypes	
-				;
-					PredOrFunc = pf_function,
-					% The output of function is always at
-					% the last.
-					list.split_last_det(ArgTypes0,
-						BeforeLast, Last),
-					ArgTypes = BeforeLast ++ RegionTypes
-						++ [Last]
-				),
-				pred_info_set_arg_types(TypeVarSet,
-					ExistQuantTVars, ArgTypes, !PredInfo),
-				module_info_set_pred_info(PredId, !.PredInfo,
-					!ModuleInfo)
-			),
-			!:Processed = [PredId | !.Processed]
-	).
-			
-	% This predicate transforms the procedures of a predicate.
-	%
+        !ModuleInfo) :-
+    PPId = proc(PredId, _),
+    ( if    list.member(PredId, !.Processed)
+      then  true
+      else  
+            some [!PredInfo] (
+                module_info_pred_info(!.ModuleInfo, PredId,
+                    !:PredInfo),
+                map.lookup(DeadRTable, PPId, DeadR),
+                map.lookup(BornRTable, PPId, BornR),
+                NumberOfRegArgs = set.count(DeadR) +
+                    set.count(BornR) + set.count(ConstantR),
+                Arity = pred_info_orig_arity(!.PredInfo),
+                pred_info_set_orig_arity(
+                    Arity + NumberOfRegArgs, !PredInfo),
+
+                list.duplicate(NumberOfRegArgs, region_type, RegionTypes),
+                pred_info_get_arg_types(!.PredInfo, TypeVarSet,
+                    ExistQuantTVars, ArgTypes0),
+                PredOrFunc =
+                    pred_info_is_pred_or_func(!.PredInfo),
+                (
+                    PredOrFunc = pf_predicate,
+                    ArgTypes = ArgTypes0 ++ RegionTypes 
+                ;
+                    PredOrFunc = pf_function,
+                    % The output of function is always at
+                    % the last.
+                    list.split_last_det(ArgTypes0,
+                        BeforeLast, Last),
+                    ArgTypes = BeforeLast ++ RegionTypes
+                        ++ [Last]
+                ),
+                pred_info_set_arg_types(TypeVarSet,
+                    ExistQuantTVars, ArgTypes, !PredInfo),
+                module_info_set_pred_info(PredId, !.PredInfo,
+                    !ModuleInfo)
+            ),
+            !:Processed = [PredId | !.Processed]
+    ).
+            
+    % This predicate transforms the procedures of a predicate.
+    %
 :- pred region_transform_pred(rpta_info_table::in, proc_region_set_table::in,
-	proc_region_set_table::in, proc_region_set_table::in,
-	proc_pp_pair_region_list_table::in,
-	renaming_table::in, renaming_table::in, annotation_table::in,
-	renaming_annotation_table::in, renaming_annotation_table::in,
-	pred_id::in, name_to_prog_var_table::in, name_to_prog_var_table::out,
-	module_info::in, module_info::out) is det.
+    proc_region_set_table::in, proc_region_set_table::in,
+    proc_pp_pair_region_list_table::in,
+    renaming_table::in, renaming_table::in, region_instruction_table::in,
+    renaming_annotation_table::in, renaming_annotation_table::in,
+    pred_id::in, name_to_prog_var_table::in, name_to_prog_var_table::out,
+    module_info::in, module_info::out) is det.
 
 region_transform_pred(RptaInfoTable, ConstantRTable, DeadRTable, BornRTable,
-		ActualRegionArgTable, ResurRenamingTable, IteRenamingTable,
-		AnnotationTable, ResurRenamingAnnoTable, IteRenamingAnnoTable,
-		PredId, !NameToVarTable, !ModuleInfo) :-
+        ActualRegionArgTable, ResurRenamingTable, IteRenamingTable,
+        RegionInstructionTable, ResurRenamingAnnoTable, IteRenamingAnnoTable,
+        PredId, !NameToVarTable, !ModuleInfo) :-
     module_info_pred_info(!.ModuleInfo, PredId, PredInfo),
     ProcIds = pred_info_non_imported_procids(PredInfo),
     list.foldl2(region_transform_proc(RptaInfoTable,
-		ConstantRTable, DeadRTable, BornRTable, ActualRegionArgTable,
-		ResurRenamingTable, IteRenamingTable,
-		AnnotationTable, ResurRenamingAnnoTable, IteRenamingAnnoTable,
-		PredId), ProcIds, !NameToVarTable, !ModuleInfo).
-
-	% This predicate updates the proc_info data structure, representing 
-	% a procedure.
-	% - Introduce new variables for regions (and their region types).
-	% - Update headvars with region arguments (types and modes).
-	% - Update the body
-	%	+ region instructions,
-	%	+ actual region arguments at call sites,
-	%	+ how_to_construct at construction unifications.
-	% - *Requantify* the annotated proc.
-	% As said above, we will recompute instmap delta, recheck purity for
-	% this annotated procedure after all the procedures have been
-	% transformed.
-	%
+        ConstantRTable, DeadRTable, BornRTable, ActualRegionArgTable,
+        ResurRenamingTable, IteRenamingTable,
+        RegionInstructionTable, ResurRenamingAnnoTable, IteRenamingAnnoTable,
+        PredId), ProcIds, !NameToVarTable, !ModuleInfo).
+
+    % This predicate updates the proc_info data structure, representing 
+    % a procedure.
+    % - Introduce new variables for regions (and their region types).
+    % - Update headvars with region arguments (types and modes).
+    % - Update the body
+    %   + region instructions,
+    %   + actual region arguments at call sites,
+    %   + how_to_construct at construction unifications.
+    % - *Requantify* the annotated proc.
+    % As said above, we will recompute instmap delta, recheck purity for
+    % this annotated procedure after all the procedures have been
+    % transformed.
+    %
 :- pred region_transform_proc(rpta_info_table::in, proc_region_set_table::in,
-	proc_region_set_table::in, proc_region_set_table::in,
-	proc_pp_pair_region_list_table::in,
-	renaming_table::in, renaming_table::in, annotation_table::in,
-	renaming_annotation_table::in, renaming_annotation_table::in,
-	pred_id::in, proc_id::in, name_to_prog_var_table::in,
-	name_to_prog_var_table::out, module_info::in, module_info::out) is det.
+    proc_region_set_table::in, proc_region_set_table::in,
+    proc_pp_pair_region_list_table::in,
+    renaming_table::in, renaming_table::in, region_instruction_table::in,
+    renaming_annotation_table::in, renaming_annotation_table::in,
+    pred_id::in, proc_id::in, name_to_prog_var_table::in,
+    name_to_prog_var_table::out, module_info::in, module_info::out) is det.
 
 region_transform_proc(RptaInfoTable, ConstantRTable, DeadRTable, BornRTable,
-		ActualRegionArgTable, ResurRenamingTable, IteRenamingTable,
-		AnnotationTable, ResurRenamingAnnoTable, IteRenamingAnnoTable,
-		PredId, ProcId, !NameToVarTable, !ModuleInfo) :-
+        ActualRegionArgTable, ResurRenamingTable, IteRenamingTable,
+        RegionInstructionTable, ResurRenamingAnnoTable, IteRenamingAnnoTable,
+        PredId, ProcId, !NameToVarTable, !ModuleInfo) :-
     PPId = proc(PredId, ProcId),
-	module_info_pred_proc_info(!.ModuleInfo, PPId, PredInfo0, ProcInfo0),
-	fill_goal_path_slots(!.ModuleInfo, ProcInfo0, ProcInfo1),
-	proc_info_get_varset(ProcInfo1, VarSet0),
-	proc_info_get_vartypes(ProcInfo1, VarTypes0),
-	proc_info_get_headvars(ProcInfo1, HeadVars0),
-	proc_info_get_argmodes(ProcInfo1, ActualArgModes0),
-	proc_info_get_goal(ProcInfo1, Goal0),
-	map.lookup(RptaInfoTable, PPId, rpta_info(Graph, _)),
-	map.lookup(ConstantRTable, PPId, ConstantR),
-	map.lookup(DeadRTable, PPId, DeadR),
-	map.lookup(BornRTable, PPId, BornR),
-	map.lookup(ActualRegionArgTable, PPId, ActualRegionArgProc),
-	( if	map.search(ResurRenamingTable, PPId, ResurRenamingProc0)
-	  then
-			ResurRenamingProc = ResurRenamingProc0,
-			map.lookup(ResurRenamingAnnoTable, PPId,
-				ResurRenamingAnnoProc)
-	  else
-			ResurRenamingProc = map.init,
-			ResurRenamingAnnoProc = map.init
-	),
-	( if	map.search(IteRenamingTable, PPId, IteRenamingProc0)
-	  then
-			IteRenamingProc = IteRenamingProc0,
-			map.lookup(IteRenamingAnnoTable, PPId,
-				IteRenamingAnnoProc)
-	  else
-			IteRenamingProc = map.init,
-			IteRenamingAnnoProc = map.init
-	),
-	map.lookup(AnnotationTable, PPId, AnnotationProc),
-	NameToVar0 = map.init,
-	annotate_proc(!.ModuleInfo, PredInfo0, Graph, ConstantR, DeadR, BornR,
-		ActualRegionArgProc, ResurRenamingProc, IteRenamingProc,
-		AnnotationProc, ResurRenamingAnnoProc, IteRenamingAnnoProc,
-		VarSet0, _, VarTypes0, _, HeadVars0, _, ActualArgModes0, _,
-		Goal0, _, NameToVar0, NameToVar, ProcInfo1, ProcInfo2),
-	requantify_proc(ProcInfo2, ProcInfo),
-	module_info_set_pred_proc_info(PPId, PredInfo0, ProcInfo, !ModuleInfo),
-	svmap.det_insert(PPId, NameToVar, !NameToVarTable).
-
-	% Currently for a procedure we annotate the following information:
-	% 1. VarSet with region variables
-	% 2. VarTypes with region variables and their types
-	% 3. HeadVars with formal region arguments
-	% 4. ActualHeadModes with the modes for region variables 
-	% 5. Body: 
-	%	+ new region arguments at calls
-	%	+ new calls to region instructions
-	%
+    module_info_pred_proc_info(!.ModuleInfo, PPId, PredInfo0, ProcInfo0),
+    fill_goal_path_slots(!.ModuleInfo, ProcInfo0, ProcInfo1),
+    proc_info_get_varset(ProcInfo1, VarSet0),
+    proc_info_get_vartypes(ProcInfo1, VarTypes0),
+    proc_info_get_headvars(ProcInfo1, HeadVars0),
+    proc_info_get_argmodes(ProcInfo1, ActualArgModes0),
+    proc_info_get_goal(ProcInfo1, Goal0),
+    map.lookup(RptaInfoTable, PPId, rpta_info(Graph, _)),
+    map.lookup(ConstantRTable, PPId, ConstantR),
+    map.lookup(DeadRTable, PPId, DeadR),
+    map.lookup(BornRTable, PPId, BornR),
+    map.lookup(ActualRegionArgTable, PPId, ActualRegionArgProc),
+    ( if    map.search(ResurRenamingTable, PPId, ResurRenamingProc0)
+      then
+            ResurRenamingProc = ResurRenamingProc0,
+            map.lookup(ResurRenamingAnnoTable, PPId,
+                ResurRenamingAnnoProc)
+      else
+            ResurRenamingProc = map.init,
+            ResurRenamingAnnoProc = map.init
+    ),
+    ( if    map.search(IteRenamingTable, PPId, IteRenamingProc0)
+      then
+            IteRenamingProc = IteRenamingProc0,
+            map.lookup(IteRenamingAnnoTable, PPId,
+                IteRenamingAnnoProc)
+      else
+            IteRenamingProc = map.init,
+            IteRenamingAnnoProc = map.init
+    ),
+    map.lookup(RegionInstructionTable, PPId, RegionInstructionProc),
+    NameToVar0 = map.init,
+    annotate_proc(!.ModuleInfo, PredInfo0, Graph, ConstantR, DeadR, BornR,
+        ActualRegionArgProc, ResurRenamingProc, IteRenamingProc,
+        RegionInstructionProc, ResurRenamingAnnoProc, IteRenamingAnnoProc,
+        VarSet0, _, VarTypes0, _, HeadVars0, _, ActualArgModes0, _,
+        Goal0, _, NameToVar0, NameToVar, ProcInfo1, ProcInfo2),
+    requantify_proc(ProcInfo2, ProcInfo),
+    module_info_set_pred_proc_info(PPId, PredInfo0, ProcInfo, !ModuleInfo),
+    svmap.det_insert(PPId, NameToVar, !NameToVarTable).
+
+    % Currently for a procedure we annotate the following information:
+    % 1. VarSet with region variables
+    % 2. VarTypes with region variables and their types
+    % 3. HeadVars with formal region arguments
+    % 4. ActualHeadModes with the modes for region variables 
+    % 5. Body: 
+    %   + new region arguments at calls
+    %   + new calls to region instructions
+    %
 :- pred annotate_proc(module_info::in, pred_info::in, rpt_graph::in,
-	region_set::in, region_set::in, region_set::in,
-	pp_pair_region_list_table::in, renaming_proc::in, renaming_proc::in,
-	annotation_proc::in, renaming_annotation_proc::in,
-	renaming_annotation_proc::in, prog_varset::in, prog_varset::out,
-	vartypes::in, vartypes::out, list(prog_var)::in, list(prog_var)::out,
-	list(mer_mode)::in, list(mer_mode)::out, hlds_goal::in, hlds_goal::out,
-	name_to_prog_var::in, name_to_prog_var::out, proc_info::in,
-	proc_info::out) is det.
+    region_set::in, region_set::in, region_set::in,
+    pp_pair_region_list_table::in, renaming_proc::in, renaming_proc::in,
+    region_instruction_proc::in, renaming_annotation_proc::in,
+    renaming_annotation_proc::in, prog_varset::in, prog_varset::out,
+    vartypes::in, vartypes::out, list(prog_var)::in, list(prog_var)::out,
+    list(mer_mode)::in, list(mer_mode)::out, hlds_goal::in, hlds_goal::out,
+    name_to_prog_var::in, name_to_prog_var::out, proc_info::in,
+    proc_info::out) is det.
 
 annotate_proc(ModuleInfo, PredInfo, Graph, ConstantR, DeadR, BornR,
-		ActualRegionArgProc, ResurRenamingProc, IteRenamingProc,
-		AnnotationProc, ResurRenamingAnnoProc, IteRenamingAnnoProc,
-		!VarSet, !VarTypes, !HeadVars, !ActualArgModes, !Goal,
-		!NameToVar, !ProcInfo) :-
-	region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
-		IteRenamingProc, ActualRegionArgProc,
-		AnnotationProc, ResurRenamingAnnoProc, IteRenamingAnnoProc,
-		!Goal, !NameToVar, !VarSet, !VarTypes),
-
-	% Add extra variables to the head of the procedure that correspond
-	% to the introduced region arguments.
-	% They are added as follows.
-	% For predicates:
-	% 	<OrigArgs> ==> <OrigArgs> <InputRegionArgs> <OutputRegionArgs>
-	%
-	% For functions:
-	% 	<OrigArgs> <RetVal> ==>
-	%		<OrigArgs> <InputRegionArgs> <OutputRegionArgs><RetVal>
-	%
-	% Note that formal region arguments are not subjected to renaming.
-	%
-	% Along with the extra arguments we also add extra modes for them.
-	set.to_sorted_list(ConstantR, LConstantR),
-	set.to_sorted_list(DeadR, LDeadR),
-	set.to_sorted_list(BornR, LBornR),
-	FormalInputNodes = LConstantR ++ LDeadR, 
-	FormalNodes = FormalInputNodes ++ LBornR,
-	list.map_foldl3(node_to_var(Graph), FormalNodes, FormalRegionArgs,
-		!NameToVar, !VarSet, !VarTypes),
-
-	InMode = in_mode,
-	OutMode = out_mode,
-	list.duplicate(list.length(FormalInputNodes), InMode, InModes),
-	list.duplicate(list.length(LBornR), OutMode, OutModes),
-
-	% Notice that the output of a function needs to be the last argument.
-	PredOrFunc = pred_info_is_pred_or_func(PredInfo),
-	(
-		PredOrFunc = pf_predicate,
-		!:HeadVars = !.HeadVars ++ FormalRegionArgs,
-		!:ActualArgModes = !.ActualArgModes ++ InModes ++ OutModes
-	;
-		PredOrFunc = pf_function,
-		list.split_last_det(!.HeadVars, BeforeLastHeadVar, LastHeadVar),
-		!:HeadVars = BeforeLastHeadVar ++ FormalRegionArgs
-			++ [LastHeadVar],
-		list.split_last_det(!.ActualArgModes, BeforeLastHeadMode,
-			LastHeadMode),
-		!:ActualArgModes = BeforeLastHeadMode ++ InModes
-			++ OutModes ++ [LastHeadMode]
-	),
-	
-	proc_info_set_varset(!.VarSet, !ProcInfo),
-	proc_info_set_goal(!.Goal, !ProcInfo),
-	proc_info_set_vartypes(!.VarTypes, !ProcInfo),
-	proc_info_set_headvars(!.HeadVars, !ProcInfo),
-	proc_info_set_argmodes(!.ActualArgModes, !ProcInfo).
-
-	% Basically, we will turn this atomic goal and all the region
-	% annotations attached to (before and after) it into a
-	% conjunction. When there is no annotation, the goal is just
-	% transformed and returned.
-	% If the newly created conjunction is a conjunct of a compounding
-	% conjunction then it will be flattened.
-	%
-	% Note: When both renamings (for resurrection and if-then-else) of a
-	% region exist at a program point, we will apply the resurrection one.
-	% This is due to the fact that when reasonning about what renaming is
-	% needed for if-then-else we have taken into account the changes 
-	% caused by renaming and annotations needed for resurrection problem.
-	% 
+        ActualRegionArgProc, ResurRenamingProc, IteRenamingProc,
+        RegionInstructionProc, ResurRenamingAnnoProc, IteRenamingAnnoProc,
+        !VarSet, !VarTypes, !HeadVars, !ActualArgModes, !Goal,
+        !NameToVar, !ProcInfo) :-
+    region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
+        IteRenamingProc, ActualRegionArgProc,
+        RegionInstructionProc, ResurRenamingAnnoProc, IteRenamingAnnoProc,
+        !Goal, !NameToVar, !VarSet, !VarTypes),
+
+    % Add extra variables to the head of the procedure that correspond
+    % to the introduced region arguments.
+    % They are added as follows.
+    % For predicates:
+    %   <OrigArgs> ==> <OrigArgs> <InputRegionArgs> <OutputRegionArgs>
+    %
+    % For functions:
+    %   <OrigArgs> <RetVal> ==>
+    %       <OrigArgs> <InputRegionArgs> <OutputRegionArgs><RetVal>
+    %
+    % Note that formal region arguments are not subjected to renaming.
+    %
+    % Along with the extra arguments we also add extra modes for them.
+    set.to_sorted_list(ConstantR, LConstantR),
+    set.to_sorted_list(DeadR, LDeadR),
+    set.to_sorted_list(BornR, LBornR),
+    FormalInputNodes = LConstantR ++ LDeadR, 
+    FormalNodes = FormalInputNodes ++ LBornR,
+    list.map_foldl3(node_to_var(Graph), FormalNodes, FormalRegionArgs,
+        !NameToVar, !VarSet, !VarTypes),
+
+    InMode = in_mode,
+    OutMode = out_mode,
+    list.duplicate(list.length(FormalInputNodes), InMode, InModes),
+    list.duplicate(list.length(LBornR), OutMode, OutModes),
+
+    % Notice that the output of a function needs to be the last argument.
+    PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+    (
+        PredOrFunc = pf_predicate,
+        !:HeadVars = !.HeadVars ++ FormalRegionArgs,
+        !:ActualArgModes = !.ActualArgModes ++ InModes ++ OutModes
+    ;
+        PredOrFunc = pf_function,
+        list.split_last_det(!.HeadVars, BeforeLastHeadVar, LastHeadVar),
+        !:HeadVars = BeforeLastHeadVar ++ FormalRegionArgs
+            ++ [LastHeadVar],
+        list.split_last_det(!.ActualArgModes, BeforeLastHeadMode,
+            LastHeadMode),
+        !:ActualArgModes = BeforeLastHeadMode ++ InModes
+            ++ OutModes ++ [LastHeadMode]
+    ),
+    
+    proc_info_set_varset(!.VarSet, !ProcInfo),
+    proc_info_set_goal(!.Goal, !ProcInfo),
+    proc_info_set_vartypes(!.VarTypes, !ProcInfo),
+    proc_info_set_headvars(!.HeadVars, !ProcInfo),
+    proc_info_set_argmodes(!.ActualArgModes, !ProcInfo).
+
+    % Basically, we will turn this atomic goal and all the region
+    % annotations attached to (before and after) it into a
+    % conjunction. When there is no annotation, the goal is just
+    % transformed and returned.
+    % If the newly created conjunction is a conjunct of a compounding
+    % conjunction then it will be flattened.
+    %
+    % Note: When both renamings (for resurrection and if-then-else) of a
+    % region exist at a program point, we will apply the resurrection one.
+    % This is due to the fact that when reasonning about what renaming is
+    % needed for if-then-else we have taken into account the changes 
+    % caused by renaming and annotations needed for resurrection problem.
+    % 
 :- pred region_transform_goal(module_info::in, rpt_graph::in,
-	renaming_proc::in, renaming_proc::in, pp_pair_region_list_table::in,
-	annotation_proc::in, renaming_annotation_proc::in,
-	renaming_annotation_proc::in, hlds_goal::in, hlds_goal::out,
-	name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
+    renaming_proc::in, renaming_proc::in, pp_pair_region_list_table::in,
+    region_instruction_proc::in, renaming_annotation_proc::in,
+    renaming_annotation_proc::in, hlds_goal::in, hlds_goal::out,
+    name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
 
 region_transform_goal(ModuleInfo, Graph, ResurRenamingProc, IteRenamingProc,
-		ActualRegionArgProc, AnnotationProc, ResurRenamingAnnoProc,
-		IteRenamingAnnoProc, !Goal, !NameToVar, !VarSet, !VarTypes) :-
+        ActualRegionArgProc, RegionInstructionProc, ResurRenamingAnnoProc,
+        IteRenamingAnnoProc, !Goal, !NameToVar, !VarSet, !VarTypes) :-
     !.Goal = hlds_goal(GoalExpr0, Info0), 
-	(	goal_is_atomic(GoalExpr0)
-	->
-		ProgPoint = program_point_init(Info0),
-		ProgPoint = pp(Context, _),
-		find_renamings_at_prog_point(ResurRenamingProc, IteRenamingProc,
-			ProgPoint, ResurRenaming, IteRenaming), 
-
-		% Depending on the expression, this call will annotate
-		% - a call with actual region arguments,
-		% - a construction unification with a region to construct in.
-		region_transform_goal_expr(ModuleInfo, Graph, ResurRenaming,
-			IteRenaming, ActualRegionArgProc, ProgPoint,
-			GoalExpr0, GoalExpr, Info0, Info, !NameToVar, !VarSet,
-			!VarTypes),
-
-		% Assignment unifications due to ite renaming.
-		assignments_from_ite_renaming_anno(IteRenamingAnnoProc,
-			ProgPoint, !NameToVar, !VarSet, !VarTypes,
-			[], IteRenamingAssignments),
-
-		% Region instructions before and after this program point.
-		(	map.search(AnnotationProc, ProgPoint,
-				before_after(Before, After))
-		->
-			% Region instructions before this program point.
-			list.foldl4(region_instruction_to_conj(ModuleInfo,
-				Context, ResurRenaming, IteRenaming), Before,
-				!NameToVar, !VarSet, !VarTypes,
-				IteRenamingAssignments, Conjs1),
-
-			% The goal at this program point itself.
-			Conjs2 = Conjs1 ++ [hlds_goal(GoalExpr, Info)],
-
-			% Region instructions after this program point.
-			list.foldl4(region_instruction_to_conj(ModuleInfo,
-				Context, ResurRenaming, IteRenaming), After,
-				!NameToVar, !VarSet, !VarTypes,
-				Conjs2, Conjs3)
-		;
-			% The goal at this program point itself.
-			Conjs3 = IteRenamingAssignments ++
-				[hlds_goal(GoalExpr, Info)]
-		),
-
-		% Assignment unifications due to region resurrection renaming.
-		assignments_from_resur_renaming_anno(ResurRenamingAnnoProc,
-			ProgPoint, IteRenaming, !NameToVar, !VarSet, !VarTypes,
-			Conjs3, Conjs),
-	
-		( if	Conjs = [_, _ | _]
-		  then
-				!:Goal = hlds_goal(conj(plain_conj, Conjs),
-					Info)
-		  else	!:Goal = hlds_goal(GoalExpr, Info)
-		)
-	;
-		region_transform_compound_goal(ModuleInfo, Graph,
-			ResurRenamingProc, IteRenamingProc, ActualRegionArgProc,
-			AnnotationProc, ResurRenamingAnnoProc,
-			IteRenamingAnnoProc, !Goal, !NameToVar, !VarSet,
-			!VarTypes)
-	).
+    (   goal_is_atomic(GoalExpr0)
+    ->
+        ProgPoint = program_point_init(Info0),
+        ProgPoint = pp(Context, _),
+        find_renamings_at_prog_point(ResurRenamingProc, IteRenamingProc,
+            ProgPoint, ResurRenaming, IteRenaming), 
+
+        % Depending on the expression, this call will annotate
+        % - a call with actual region arguments,
+        % - a construction unification with a region to construct in.
+        region_transform_goal_expr(ModuleInfo, Graph, ResurRenaming,
+            IteRenaming, ActualRegionArgProc, ProgPoint,
+            GoalExpr0, GoalExpr, Info0, Info, !NameToVar, !VarSet,
+            !VarTypes),
+
+        % Assignment unifications due to ite renaming.
+        assignments_from_ite_renaming_anno(IteRenamingAnnoProc,
+            ProgPoint, !NameToVar, !VarSet, !VarTypes,
+            [], IteRenamingAssignments),
+
+        % Region instructions before and after this program point.
+        (   map.search(RegionInstructionProc, ProgPoint,
+                insts_before_after(Before, After))
+        ->
+            % Region instructions before this program point.
+            list.foldl4(region_instruction_to_conj(ModuleInfo,
+                Context, ResurRenaming, IteRenaming), Before,
+                !NameToVar, !VarSet, !VarTypes,
+                IteRenamingAssignments, Conjs1),
+
+            % The goal at this program point itself.
+            Conjs2 = Conjs1 ++ [hlds_goal(GoalExpr, Info)],
+
+            % Region instructions after this program point.
+            list.foldl4(region_instruction_to_conj(ModuleInfo,
+                Context, ResurRenaming, IteRenaming), After,
+                !NameToVar, !VarSet, !VarTypes,
+                Conjs2, Conjs3)
+        ;
+            % The goal at this program point itself.
+            Conjs3 = IteRenamingAssignments ++
+                [hlds_goal(GoalExpr, Info)]
+        ),
+
+        % Assignment unifications due to region resurrection renaming.
+        assignments_from_resur_renaming_anno(ResurRenamingAnnoProc,
+            ProgPoint, IteRenaming, !NameToVar, !VarSet, !VarTypes,
+            Conjs3, Conjs),
+    
+        ( if    Conjs = [_, _ | _]
+          then
+                !:Goal = hlds_goal(conj(plain_conj, Conjs),
+                    Info)
+          else  !:Goal = hlds_goal(GoalExpr, Info)
+        )
+    ;
+        region_transform_compound_goal(ModuleInfo, Graph,
+            ResurRenamingProc, IteRenamingProc, ActualRegionArgProc,
+            RegionInstructionProc, ResurRenamingAnnoProc,
+            IteRenamingAnnoProc, !Goal, !NameToVar, !VarSet,
+            !VarTypes)
+    ).
 
 :- pred region_transform_goal_expr(module_info::in, rpt_graph::in,
-	renaming::in, renaming::in, pp_pair_region_list_table::in,
-	program_point::in, hlds_goal_expr::in, hlds_goal_expr::out,
-	hlds_goal_info::in, hlds_goal_info::out, name_to_prog_var::in,
-	name_to_prog_var::out, prog_varset::in, prog_varset::out,
-	vartypes::in, vartypes::out) is det.
+    renaming::in, renaming::in, pp_pair_region_list_table::in,
+    program_point::in, hlds_goal_expr::in, hlds_goal_expr::out,
+    hlds_goal_info::in, hlds_goal_info::out, name_to_prog_var::in,
+    name_to_prog_var::out, prog_varset::in, prog_varset::out,
+    vartypes::in, vartypes::out) is det.
 
-	% Annotate procedure calls with actual region arguments.
-	%
+    % Annotate procedure calls with actual region arguments.
+    %
 region_transform_goal_expr(_, Graph, ResurRenaming, IteRenaming,
-		ActualRegionArgProc, ProgPoint, !GoalExpr, !GoalInfo,
-		!NameToVar, !VarSet, !VarTypes) :-
-	!.GoalExpr = plain_call(CalleePredId, CalleeProcId, Args0, Builtin,
-		Context, Name),
-	% XXX Callee may be a builtin or an imported procedure that we have
-	% not analysed, we just ignore such a call for now.
-	( if	map.search(ActualRegionArgProc, ProgPoint, ActualNodes0)
-	  then	ActualNodes = ActualNodes0
-	  else	ActualNodes = pair([],[])
-	),
-	ActualNodes = Ins - Outs,
-	AllNodes = Ins ++ Outs,
-	list.map_foldl3(node_to_var_with_both_renamings(Graph,
-		ResurRenaming, IteRenaming),
-		AllNodes, ActualRegionArgs, !NameToVar, !VarSet, !VarTypes),
-	Args = Args0 ++ ActualRegionArgs,
-	!:GoalExpr = plain_call(CalleePredId, CalleeProcId, Args, Builtin,
-		Context, Name).
+        ActualRegionArgProc, ProgPoint, !GoalExpr, !GoalInfo,
+        !NameToVar, !VarSet, !VarTypes) :-
+    !.GoalExpr = plain_call(CalleePredId, CalleeProcId, Args0, Builtin,
+        Context, Name),
+    % XXX Callee may be a builtin or an imported procedure that we have
+    % not analysed, we just ignore such a call for now.
+    ( if    map.search(ActualRegionArgProc, ProgPoint, ActualNodes0)
+      then  ActualNodes = ActualNodes0
+      else  ActualNodes = pair([],[])
+    ),
+    ActualNodes = Ins - Outs,
+    AllNodes = Ins ++ Outs,
+    list.map_foldl3(node_to_var_with_both_renamings(Graph,
+        ResurRenaming, IteRenaming),
+        AllNodes, ActualRegionArgs, !NameToVar, !VarSet, !VarTypes),
+    Args = Args0 ++ ActualRegionArgs,
+    !:GoalExpr = plain_call(CalleePredId, CalleeProcId, Args, Builtin,
+        Context, Name).
 
-	% Annotate construction unifications with regions to construct in.
-	%
+    % Annotate construction unifications with regions to construct in.
+    %
 region_transform_goal_expr(ModuleInfo, Graph, ResurRenaming, IteRenaming,
-		_, _, !GoalExpr, !GoalInfo, !NameToVar, !VarSet, !VarTypes) :-
-	!.GoalExpr = unify(LHS, RHS, Mode, Unification0, Context),
+        _, _, !GoalExpr, !GoalInfo, !NameToVar, !VarSet, !VarTypes) :-
+    !.GoalExpr = unify(LHS, RHS, Mode, Unification0, Context),
     annotate_constructions_unification(ModuleInfo, Graph, ResurRenaming,
-		IteRenaming, Unification0, Unification, !NameToVar, !VarSet,
-		!VarTypes),
-	!:GoalExpr = unify(LHS, RHS, Mode, Unification, Context).
+        IteRenaming, Unification0, Unification, !NameToVar, !VarSet,
+        !VarTypes),
+    !:GoalExpr = unify(LHS, RHS, Mode, Unification, Context).
 
 region_transform_goal_expr(_, _, _, _, _, _, !GoalExpr, !GoalInfo, !NameToVar,
-		!VarSet, !VarTypes) :-
-	!.GoalExpr = generic_call(_, _, _, _),
-	sorry(this_file,
-		"region_transform_goal_expr: generic call is not handled.").
+        !VarSet, !VarTypes) :-
+    !.GoalExpr = generic_call(_, _, _, _),
+    sorry(this_file,
+        "region_transform_goal_expr: generic call is not handled.").
 
 region_transform_goal_expr(_, _, _, _, _, _, !GoalExpr, !GoalInfo, !NameToVar,
-		!VarSet, !VarTypes) :-
-	!.GoalExpr = call_foreign_proc(_, _, _, _, _, _, _),
-	sorry(this_file, "region_transform_goal_expr: " ++
-		"call to foreign procedure is not handled").
+        !VarSet, !VarTypes) :-
+    !.GoalExpr = call_foreign_proc(_, _, _, _, _, _, _),
+    sorry(this_file, "region_transform_goal_expr: " ++
+        "call to foreign procedure is not handled").
 
 region_transform_goal_expr(_, _, _, _, _, _, !GoalExpr, !GoalInfo, !NameToVar,
-		!VarSet, !VarTypes) :-
-	( !.GoalExpr = conj(_, [])
-	; !.GoalExpr = disj([])
-	).
+        !VarSet, !VarTypes) :-
+    ( !.GoalExpr = conj(_, [])
+    ; !.GoalExpr = disj([])
+    ).
 
 region_transform_goal_expr(_, _, _, _, _, _, !GoalExpr, !GoalInfo, !NameToVar,
-		!VarSet, !VarTypes) :-
-	( !.GoalExpr = conj(_, [_ | _])
-	; !.GoalExpr = disj([_ | _])
-	; !.GoalExpr = if_then_else(_, _, _, _)
-	; !.GoalExpr = negation(_)
-	; !.GoalExpr = switch(_, _, _)
-	; !.GoalExpr = scope(_, _)
-	; !.GoalExpr = shorthand(_)  
-	),
-	unexpected(this_file,
-		"region_transform_goal_expr: encounter compound goal").
+        !VarSet, !VarTypes) :-
+    ( !.GoalExpr = conj(_, [_ | _])
+    ; !.GoalExpr = disj([_ | _])
+    ; !.GoalExpr = if_then_else(_, _, _, _)
+    ; !.GoalExpr = negation(_)
+    ; !.GoalExpr = switch(_, _, _)
+    ; !.GoalExpr = scope(_, _)
+    ; !.GoalExpr = shorthand(_)  
+    ),
+    unexpected(this_file,
+        "region_transform_goal_expr: encounter compound goal").
 
-	% Because an atomic goal is turned into a conjunction, we need to
-	% flatten its compounding conjunction if it is in one.
+    % Because an atomic goal is turned into a conjunction, we need to
+    % flatten its compounding conjunction if it is in one.
 :- pred region_transform_compound_goal(module_info::in, rpt_graph::in,
-	renaming_proc::in, renaming_proc::in, pp_pair_region_list_table::in,
-	annotation_proc::in, renaming_annotation_proc::in,
-	renaming_annotation_proc::in, hlds_goal::in, hlds_goal::out,
-	name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
+    renaming_proc::in, renaming_proc::in, pp_pair_region_list_table::in,
+    region_instruction_proc::in, renaming_annotation_proc::in,
+    renaming_annotation_proc::in, hlds_goal::in, hlds_goal::out,
+    name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
 
 region_transform_compound_goal(ModuleInfo, Graph,
-		ResurRenamingProc, IteRenamingProc, ActualRegionArgProc,
-		AnnotationProc, ResurRenamingAnnoProc, IteRenamingAnnoProc,
-		hlds_goal(!.GoalExpr, !.GoalInfo), hlds_goal(!:GoalExpr, !:GoalInfo),
-		!NameToVar, !VarSet, !VarTypes) :-
-	(
-		!.GoalExpr = conj(ConjType, [Conj0 | Conjs0]),
-		list.map_foldl3(region_transform_goal(ModuleInfo, Graph,
-			ResurRenamingProc, IteRenamingProc,
-			ActualRegionArgProc, AnnotationProc,
-			ResurRenamingAnnoProc, IteRenamingAnnoProc),
-			[Conj0 | Conjs0], Conjs1, !NameToVar, !VarSet,
-			!VarTypes),
-		flatten_conj(Conjs1, Conjs),
-		!:GoalExpr = conj(ConjType, Conjs)
-	;
-		!.GoalExpr = disj([Disj0 | Disjs0]),
-		list.map_foldl3(region_transform_goal(ModuleInfo, Graph,
-			ResurRenamingProc, IteRenamingProc,
-			ActualRegionArgProc, AnnotationProc,
-			ResurRenamingAnnoProc, IteRenamingAnnoProc),
-			[Disj0 | Disjs0], Disjs, !NameToVar, !VarSet,
-			!VarTypes),
-		!:GoalExpr = disj(Disjs)
-	;
-		!.GoalExpr = switch(Var, CanFail, Cases0),
-		list.map_foldl3(region_transform_case(ModuleInfo, Graph,
-			ResurRenamingProc, IteRenamingProc,
-			ActualRegionArgProc, AnnotationProc,
-			ResurRenamingAnnoProc, IteRenamingAnnoProc,
-			hlds_goal(!.GoalExpr, !.GoalInfo)),
-			Cases0, Cases, !NameToVar, !VarSet, !VarTypes),
-		!:GoalExpr = switch(Var, CanFail, Cases)
-	;
-		!.GoalExpr = negation(Goal0),
-		region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
-			IteRenamingProc, ActualRegionArgProc, AnnotationProc,
-			ResurRenamingAnnoProc, IteRenamingAnnoProc, Goal0, Goal,
-			!NameToVar, !VarSet, !VarTypes),
-		!:GoalExpr = negation(Goal)
-	;
-		!.GoalExpr = scope(Reason, Goal0),
-		region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
-			IteRenamingProc, ActualRegionArgProc, AnnotationProc,
-			ResurRenamingAnnoProc, IteRenamingAnnoProc, Goal0, Goal,
-			!NameToVar, !VarSet, !VarTypes),
-		!:GoalExpr = scope(Reason, Goal)
-	;
-		!.GoalExpr = if_then_else(Vars, Cond0, Then0, Else0),
-		region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
-			IteRenamingProc, ActualRegionArgProc, AnnotationProc,
-			ResurRenamingAnnoProc, IteRenamingAnnoProc, Cond0, Cond,
-			!NameToVar, !VarSet, !VarTypes),
-		region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
-			IteRenamingProc, ActualRegionArgProc, AnnotationProc,
-			ResurRenamingAnnoProc, IteRenamingAnnoProc, Then0, Then,
-			!NameToVar, !VarSet, !VarTypes),
-		region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
-			IteRenamingProc, ActualRegionArgProc, AnnotationProc,
-			ResurRenamingAnnoProc, IteRenamingAnnoProc, Else0, Else,
-			!NameToVar, !VarSet, !VarTypes),
-		!:GoalExpr = if_then_else(Vars, Cond, Then, Else)
-	;	
-		( !.GoalExpr = shorthand(_)
-		; !.GoalExpr = unify(_, _, _, _, _)
-		; !.GoalExpr = plain_call(_, _, _, _, _, _)
-		; !.GoalExpr = generic_call(_, _, _, _)
-		; !.GoalExpr = call_foreign_proc(_, _, _, _, _, _, _)
-		; !.GoalExpr = conj(_, [])
-		; !.GoalExpr = disj([])
-		),
-		unexpected(this_file, "region_transform_compound_goal: " ++
-			"encounter shorthand or atomic goal")
-	).
-
-	% This predicate needs to be consistent with what are done in
-	% unify_gen.m, i.e., we will change how_to_construct to 
-	% construct_in_region(RegVar) only when the term is actually 
-	% stored in the heap.
-	% The current implementation may not be correct.
-	%
+        ResurRenamingProc, IteRenamingProc, ActualRegionArgProc,
+        RegionInstructionProc, ResurRenamingAnnoProc, IteRenamingAnnoProc,
+        hlds_goal(!.GoalExpr, !.GoalInfo), hlds_goal(!:GoalExpr, !:GoalInfo),
+        !NameToVar, !VarSet, !VarTypes) :-
+    (
+        !.GoalExpr = conj(ConjType, [Conj0 | Conjs0]),
+        list.map_foldl3(region_transform_goal(ModuleInfo, Graph,
+            ResurRenamingProc, IteRenamingProc,
+            ActualRegionArgProc, RegionInstructionProc,
+            ResurRenamingAnnoProc, IteRenamingAnnoProc),
+            [Conj0 | Conjs0], Conjs1, !NameToVar, !VarSet,
+            !VarTypes),
+        flatten_conj(Conjs1, Conjs),
+        !:GoalExpr = conj(ConjType, Conjs)
+    ;
+        !.GoalExpr = disj([Disj0 | Disjs0]),
+        list.map_foldl3(region_transform_goal(ModuleInfo, Graph,
+            ResurRenamingProc, IteRenamingProc,
+            ActualRegionArgProc, RegionInstructionProc,
+            ResurRenamingAnnoProc, IteRenamingAnnoProc),
+            [Disj0 | Disjs0], Disjs, !NameToVar, !VarSet,
+            !VarTypes),
+        !:GoalExpr = disj(Disjs)
+    ;
+        !.GoalExpr = switch(Var, CanFail, Cases0),
+        list.map_foldl3(region_transform_case(ModuleInfo, Graph,
+            ResurRenamingProc, IteRenamingProc,
+            ActualRegionArgProc, RegionInstructionProc,
+            ResurRenamingAnnoProc, IteRenamingAnnoProc,
+            hlds_goal(!.GoalExpr, !.GoalInfo)),
+            Cases0, Cases, !NameToVar, !VarSet, !VarTypes),
+        !:GoalExpr = switch(Var, CanFail, Cases)
+    ;
+        !.GoalExpr = negation(Goal0),
+        region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
+            IteRenamingProc, ActualRegionArgProc, RegionInstructionProc,
+            ResurRenamingAnnoProc, IteRenamingAnnoProc, Goal0, Goal,
+            !NameToVar, !VarSet, !VarTypes),
+        !:GoalExpr = negation(Goal)
+    ;
+        !.GoalExpr = scope(Reason, Goal0),
+        region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
+            IteRenamingProc, ActualRegionArgProc, RegionInstructionProc,
+            ResurRenamingAnnoProc, IteRenamingAnnoProc, Goal0, Goal,
+            !NameToVar, !VarSet, !VarTypes),
+        !:GoalExpr = scope(Reason, Goal)
+    ;
+        !.GoalExpr = if_then_else(Vars, Cond0, Then0, Else0),
+        region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
+            IteRenamingProc, ActualRegionArgProc, RegionInstructionProc,
+            ResurRenamingAnnoProc, IteRenamingAnnoProc, Cond0, Cond,
+            !NameToVar, !VarSet, !VarTypes),
+        region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
+            IteRenamingProc, ActualRegionArgProc, RegionInstructionProc,
+            ResurRenamingAnnoProc, IteRenamingAnnoProc, Then0, Then,
+            !NameToVar, !VarSet, !VarTypes),
+        region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
+            IteRenamingProc, ActualRegionArgProc, RegionInstructionProc,
+            ResurRenamingAnnoProc, IteRenamingAnnoProc, Else0, Else,
+            !NameToVar, !VarSet, !VarTypes),
+        !:GoalExpr = if_then_else(Vars, Cond, Then, Else)
+    ;   
+        ( !.GoalExpr = shorthand(_)
+        ; !.GoalExpr = unify(_, _, _, _, _)
+        ; !.GoalExpr = plain_call(_, _, _, _, _, _)
+        ; !.GoalExpr = generic_call(_, _, _, _)
+        ; !.GoalExpr = call_foreign_proc(_, _, _, _, _, _, _)
+        ; !.GoalExpr = conj(_, [])
+        ; !.GoalExpr = disj([])
+        ),
+        unexpected(this_file, "region_transform_compound_goal: " ++
+            "encounter shorthand or atomic goal")
+    ).
+
+    % This predicate needs to be consistent with what are done in
+    % unify_gen.m, i.e., we will change how_to_construct to 
+    % construct_in_region(RegVar) only when the term is actually 
+    % stored in the heap.
+    % The current implementation may not be correct.
+    %
 :- pred annotate_constructions_unification(module_info::in, rpt_graph::in,
-	renaming::in, renaming::in, unification::in, unification::out,
-	name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
+    renaming::in, renaming::in, unification::in, unification::out,
+    name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
 
 annotate_constructions_unification(ModuleInfo, Graph, ResurRenaming,
-		IteRenaming, !Unification, !NameToVar, !VarSet, !VarTypes) :-
-	!.Unification = construct(Var, ConsId, Args, ArgModes, _HowToConstruct0,
-		IsUnique, SubInfo),
-	get_node_by_variable(Graph, Var, Node),
-	NodeType = rptg_lookup_node_type(Graph, Node),
-	( if	( type_is_atomic(ModuleInfo, NodeType)
-			; is_dummy_argument_type(ModuleInfo, NodeType)
-			)
-	  then  true
-	  else
-		Name = rptg_lookup_region_name(Graph, Node),
-		region_name_to_var_with_both_renamings(Name, ResurRenaming,
-			IteRenaming, RegVar, !NameToVar, !VarSet, !VarTypes),
-		HowToConstruct = construct_in_region(RegVar),
-		!:Unification = construct(Var, ConsId, Args, ArgModes,
-			HowToConstruct, IsUnique, SubInfo)
-	).
+        IteRenaming, !Unification, !NameToVar, !VarSet, !VarTypes) :-
+    !.Unification = construct(Var, ConsId, Args, ArgModes, _HowToConstruct0,
+        IsUnique, SubInfo),
+    get_node_by_variable(Graph, Var, Node),
+    NodeType = rptg_lookup_node_type(Graph, Node),
+    ( if    ( type_is_atomic(ModuleInfo, NodeType)
+            ; is_dummy_argument_type(ModuleInfo, NodeType)
+            )
+      then  true
+      else
+        Name = rptg_lookup_region_name(Graph, Node),
+        region_name_to_var_with_both_renamings(Name, ResurRenaming,
+            IteRenaming, RegVar, !NameToVar, !VarSet, !VarTypes),
+        HowToConstruct = construct_in_region(RegVar),
+        !:Unification = construct(Var, ConsId, Args, ArgModes,
+            HowToConstruct, IsUnique, SubInfo)
+    ).
 
 annotate_constructions_unification(_, _, _, _, !Unification, !VarSet,
-		!VarTypes, !NameToVar) :-
-	(
-		( !.Unification = deconstruct(_, _, _, _, _, _)
-		; !.Unification = assign(_, _)
-		; !.Unification = simple_test(_, _)
-		)
-	;
-		!.Unification = complicated_unify(_, _, _),
-		unexpected(this_file, "annotate_construction_unification: "
-			++ "encounter complicated unify")
-	).
-	
-	% The process here is related to the way we treat the unifications 
-	% between the switch vars and a constant or a functor of arity zero.
-	% For more information about the treatment, see rbmm.execution_path.m.
-	% These unifications are not explicitly present in the goal but we 
-	% still need to insert annotations derived for them into the goal.
-	% Therefore we will make a conjunction of the annotations attached to an
-	% implicit unification. We transform the goal separately. Then we make
-	% another conjunction of the conjunction and the transformed goal.
-	% Finally, we try to flatten this new conjunction.
-	%
+        !VarTypes, !NameToVar) :-
+    (
+        ( !.Unification = deconstruct(_, _, _, _, _, _)
+        ; !.Unification = assign(_, _)
+        ; !.Unification = simple_test(_, _)
+        )
+    ;
+        !.Unification = complicated_unify(_, _, _),
+        unexpected(this_file, "annotate_construction_unification: "
+            ++ "encounter complicated unify")
+    ).
+    
+    % The process here is related to the way we treat the unifications 
+    % between the switch vars and a constant or a functor of arity zero.
+    % For more information about the treatment, see rbmm.execution_path.m.
+    % These unifications are not explicitly present in the goal but we 
+    % still need to insert annotations derived for them into the goal.
+    % Therefore we will make a conjunction of the annotations attached to an
+    % implicit unification. We transform the goal separately. Then we make
+    % another conjunction of the conjunction and the transformed goal.
+    % Finally, we try to flatten this new conjunction.
+    %
 :- pred region_transform_case(module_info::in, rpt_graph::in,
-	renaming_proc::in, renaming_proc::in, pp_pair_region_list_table::in,
-	annotation_proc::in, renaming_annotation_proc::in,
-	renaming_annotation_proc::in, hlds_goal::in, case::in, case::out,
-	name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
+    renaming_proc::in, renaming_proc::in, pp_pair_region_list_table::in,
+    region_instruction_proc::in, renaming_annotation_proc::in,
+    renaming_annotation_proc::in, hlds_goal::in, case::in, case::out,
+    name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
 
 region_transform_case(ModuleInfo, Graph, ResurRenamingProc,
-		IteRenamingProc, ActualRegionArgProc, AnnotationProc,
-		ResurRenamingAnnoProc, IteRenamingAnnoProc, Switch,
-		case(ConsId, !.Goal), case(ConsId, !:Goal),
-		!NameToVar, !VarSet, !VarTypes) :-
-	(	( ConsId = cons(_, 0)
-		; ConsId = int_const(_)
-		; ConsId = string_const(_)
-		; ConsId = float_const(_)
-		),
-		Switch = hlds_goal(switch(_, _, _), Info)
-	->
-		ProgPoint = program_point_init(Info),
-		ProgPoint = pp(Context, _),
-		find_renamings_at_prog_point(ResurRenamingProc, IteRenamingProc,
-			ProgPoint, ResurRenaming, IteRenaming), 
-
-		% Assignment unifications due to ite renaming.
-		assignments_from_ite_renaming_anno(IteRenamingAnnoProc,
-			ProgPoint, !NameToVar, !VarSet, !VarTypes,
-			[], IteRenamingAssignments),
-
-		% Region instructions before and after this program
-		% point.
-		(	map.search(AnnotationProc, ProgPoint,
-				before_after(Before, After))
-		->
-			% Region instructions before this program point.
-			list.foldl4(region_instruction_to_conj(
-				ModuleInfo, Context, ResurRenaming,
-				IteRenaming), Before, !NameToVar,
-				!VarSet, !VarTypes,
-				IteRenamingAssignments, Conjs1),
-
-			% Region instructions after this program point.
-			list.foldl4(region_instruction_to_conj(
-				ModuleInfo, Context, ResurRenaming,
-				IteRenaming), After, !NameToVar,
-				!VarSet, !VarTypes, Conjs1, Conjs2)
-		;
-			Conjs2 = IteRenamingAssignments
-		),
-
-		% Assignment unifications due to region resurrection
-		% renaming.
-		assignments_from_resur_renaming_anno(ResurRenamingAnnoProc,
-			ProgPoint, IteRenaming, !NameToVar, !VarSet, !VarTypes,
-			Conjs2, Conjs),
-	
-		RemovedGoal = hlds_goal(conj(plain_conj, Conjs), Info)
-	;
-		Switch = hlds_goal(_, Info),
-		RemovedGoal = hlds_goal(conj(plain_conj, []), Info)	
-	),
-	region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
-		IteRenamingProc, ActualRegionArgProc, AnnotationProc,
-		ResurRenamingAnnoProc, IteRenamingAnnoProc, !Goal, !NameToVar,
-		!VarSet, !VarTypes),
-	flatten_conj([RemovedGoal, !.Goal], FlatConjs),
-	Switch = hlds_goal(_, ConjsInfo),
-	!:Goal = hlds_goal(conj(plain_conj, FlatConjs), ConjsInfo).
+        IteRenamingProc, ActualRegionArgProc, RegionInstructionProc,
+        ResurRenamingAnnoProc, IteRenamingAnnoProc, Switch,
+        case(ConsId, !.Goal), case(ConsId, !:Goal),
+        !NameToVar, !VarSet, !VarTypes) :-
+    (   ( ConsId = cons(_, 0)
+        ; ConsId = int_const(_)
+        ; ConsId = string_const(_)
+        ; ConsId = float_const(_)
+        ),
+        Switch = hlds_goal(switch(_, _, _), Info)
+    ->
+        ProgPoint = program_point_init(Info),
+        ProgPoint = pp(Context, _),
+        find_renamings_at_prog_point(ResurRenamingProc, IteRenamingProc,
+            ProgPoint, ResurRenaming, IteRenaming), 
+
+        % Assignment unifications due to ite renaming.
+        assignments_from_ite_renaming_anno(IteRenamingAnnoProc,
+            ProgPoint, !NameToVar, !VarSet, !VarTypes,
+            [], IteRenamingAssignments),
+
+        % Region instructions before and after this program
+        % point.
+        (   map.search(RegionInstructionProc, ProgPoint,
+                insts_before_after(Before, After))
+        ->
+            % Region instructions before this program point.
+            list.foldl4(region_instruction_to_conj(
+                ModuleInfo, Context, ResurRenaming,
+                IteRenaming), Before, !NameToVar,
+                !VarSet, !VarTypes,
+                IteRenamingAssignments, Conjs1),
+
+            % Region instructions after this program point.
+            list.foldl4(region_instruction_to_conj(
+                ModuleInfo, Context, ResurRenaming,
+                IteRenaming), After, !NameToVar,
+                !VarSet, !VarTypes, Conjs1, Conjs2)
+        ;
+            Conjs2 = IteRenamingAssignments
+        ),
+
+        % Assignment unifications due to region resurrection
+        % renaming.
+        assignments_from_resur_renaming_anno(ResurRenamingAnnoProc,
+            ProgPoint, IteRenaming, !NameToVar, !VarSet, !VarTypes,
+            Conjs2, Conjs),
+    
+        RemovedGoal = hlds_goal(conj(plain_conj, Conjs), Info)
+    ;
+        Switch = hlds_goal(_, Info),
+        RemovedGoal = hlds_goal(conj(plain_conj, []), Info) 
+    ),
+    region_transform_goal(ModuleInfo, Graph, ResurRenamingProc,
+        IteRenamingProc, ActualRegionArgProc, RegionInstructionProc,
+        ResurRenamingAnnoProc, IteRenamingAnnoProc, !Goal, !NameToVar,
+        !VarSet, !VarTypes),
+    flatten_conj([RemovedGoal, !.Goal], FlatConjs),
+    Switch = hlds_goal(_, ConjsInfo),
+    !:Goal = hlds_goal(conj(plain_conj, FlatConjs), ConjsInfo).
 
 :- pred find_renamings_at_prog_point(renaming_proc::in, renaming_proc::in,
-	program_point::in, renaming::out, renaming::out) is det.
+    program_point::in, renaming::out, renaming::out) is det.
 
 find_renamings_at_prog_point(ResurRenamingProc, IteRenamingProc, ProgPoint,
-		ResurRenaming, IteRenaming) :-
-	( if	map.search(ResurRenamingProc, ProgPoint, ResurRenaming0)
-	  then	ResurRenaming = ResurRenaming0
-	  else	ResurRenaming = map.init
-	),
-	( if	map.search(IteRenamingProc, ProgPoint, IteRenaming0)
-	  then	IteRenaming = IteRenaming0
-	  else	IteRenaming = map.init
-	).
+        ResurRenaming, IteRenaming) :-
+    ( if    map.search(ResurRenamingProc, ProgPoint, ResurRenaming0)
+      then  ResurRenaming = ResurRenaming0
+      else  ResurRenaming = map.init
+    ),
+    ( if    map.search(IteRenamingProc, ProgPoint, IteRenaming0)
+      then  IteRenaming = IteRenaming0
+      else  IteRenaming = map.init
+    ).
 
 :- pred assignments_from_ite_renaming_anno(renaming_annotation_proc::in,
-	program_point::in, name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out,
-	hlds_goals::in, hlds_goals::out) is det.
+    program_point::in, name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out,
+    hlds_goals::in, hlds_goals::out) is det.
 
 assignments_from_ite_renaming_anno(IteRenamingAnnoProc, ProgPoint,
-		!NameToVar, !VarSet, !VarTypes, !IteRenamingAssignments) :-
-	% Assignment unifications due to ite renaming.
-	(	map.search(IteRenamingAnnoProc, ProgPoint, IteRenamingAnnos)
-	->
-		list.foldl4(ite_renaming_annotation_to_assignment,
-			IteRenamingAnnos, !NameToVar, !VarSet, !VarTypes,
-			!IteRenamingAssignments)
-	;	true
-	).
+        !NameToVar, !VarSet, !VarTypes, !IteRenamingAssignments) :-
+    % Assignment unifications due to ite renaming.
+    (   map.search(IteRenamingAnnoProc, ProgPoint, IteRenamingAnnos)
+    ->
+        list.foldl4(ite_renaming_annotation_to_assignment,
+            IteRenamingAnnos, !NameToVar, !VarSet, !VarTypes,
+            !IteRenamingAssignments)
+    ;   true
+    ).
 
 :- pred assignments_from_resur_renaming_anno(renaming_annotation_proc::in,
-	program_point::in, renaming::in, name_to_prog_var::in,
-	name_to_prog_var::out, prog_varset::in, prog_varset::out,
-	vartypes::in, vartypes::out, hlds_goals::in, hlds_goals::out) is det.
+    program_point::in, renaming::in, name_to_prog_var::in,
+    name_to_prog_var::out, prog_varset::in, prog_varset::out,
+    vartypes::in, vartypes::out, hlds_goals::in, hlds_goals::out) is det.
 
 assignments_from_resur_renaming_anno(ResurRenamingAnnoProc, ProgPoint,
-		IteRenaming, !NameToVar, !VarSet, !VarTypes, !Conjs) :-
-	(	map.search(ResurRenamingAnnoProc, ProgPoint,
-			ResurRenamingAnnos)
-	->
-		list.foldl4(resur_renaming_annotation_to_assignment(
-			IteRenaming), ResurRenamingAnnos, !NameToVar, !VarSet,
-			!VarTypes, !Conjs)
-	;	true
-	).
-
-	% Return the program variable representing the region which is
-	% represented by the node in the points-to graph.
-	% Come up with a new program variable if none exists yet.
-	% Each node is associated with a region name, so this predicate just
-	% delegates the task for region_name_to_var.
-	%
+        IteRenaming, !NameToVar, !VarSet, !VarTypes, !Conjs) :-
+    (   map.search(ResurRenamingAnnoProc, ProgPoint,
+            ResurRenamingAnnos)
+    ->
+        list.foldl4(resur_renaming_annotation_to_assignment(
+            IteRenaming), ResurRenamingAnnos, !NameToVar, !VarSet,
+            !VarTypes, !Conjs)
+    ;   true
+    ).
+
+    % Return the program variable representing the region which is
+    % represented by the node in the points-to graph.
+    % Come up with a new program variable if none exists yet.
+    % Each node is associated with a region name, so this predicate just
+    % delegates the task for region_name_to_var.
+    %
 :- pred node_to_var(rpt_graph::in, rptg_node::in,
-	prog_var::out, name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
+    prog_var::out, name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
 
 node_to_var(Graph, Node, RegVar, !NameToVar, !VarSet,
-		!VarTypes) :-
-	RegName = rptg_lookup_region_name(Graph, Node),
-	region_name_to_var(RegName, RegVar, !NameToVar, !VarSet, !VarTypes).
+        !VarTypes) :-
+    RegName = rptg_lookup_region_name(Graph, Node),
+    region_name_to_var(RegName, RegVar, !NameToVar, !VarSet, !VarTypes).
  
-	% Return the program variable representing the region name.
-	% Come up with a new one if none exists.
-	%
+    % Return the program variable representing the region name.
+    % Come up with a new one if none exists.
+    %
 :- pred region_name_to_var(string::in, prog_var::out,
-	name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
+    name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
 
 region_name_to_var(Name, RegVar, !NameToVar, !VarSet, !VarTypes) :-
-	( if	map.search(!.NameToVar, Name, RegVar0)
-	  then	RegVar = RegVar0
-	  else
-			svvarset.new_named_var(Name, RegVar, !VarSet),
-			svmap.det_insert(RegVar, make_region_type, !VarTypes),
-			svmap.det_insert(Name, RegVar, !NameToVar)
-	).
-
-	% The same as node_to_var, but the corresponding region name is 
-	% subjected to resurrection and if-then-else renaming beforehand.
-	%
+    ( if    map.search(!.NameToVar, Name, RegVar0)
+      then  RegVar = RegVar0
+      else
+            svvarset.new_named_var(Name, RegVar, !VarSet),
+            svmap.det_insert(RegVar, region_type, !VarTypes),
+            svmap.det_insert(Name, RegVar, !NameToVar)
+    ).
+
+    % The same as node_to_var, but the corresponding region name is 
+    % subjected to resurrection and if-then-else renaming beforehand.
+    %
 :- pred node_to_var_with_both_renamings(rpt_graph::in, renaming::in,
-	renaming::in, rptg_node::in, prog_var::out,
-	name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
+    renaming::in, rptg_node::in, prog_var::out,
+    name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
 
 node_to_var_with_both_renamings(Graph, ResurRenaming, IteRenaming,
-		Node, RegVar, !NameToVar, !VarSet, !VarTypes) :-
-	RegName = rptg_lookup_region_name(Graph, Node),
-	region_name_to_var_with_both_renamings(RegName, ResurRenaming,
-		IteRenaming, RegVar, !NameToVar, !VarSet, !VarTypes).
-
-	% Resurrection renaming will be applied first. If a renaming exists
-	% for the name (i.e., the name will be changed to another name) then
-	% ite renaming need not to be applied because actually it is not
-	% applicable anymore.
-	%
+        Node, RegVar, !NameToVar, !VarSet, !VarTypes) :-
+    RegName = rptg_lookup_region_name(Graph, Node),
+    region_name_to_var_with_both_renamings(RegName, ResurRenaming,
+        IteRenaming, RegVar, !NameToVar, !VarSet, !VarTypes).
+
+    % Resurrection renaming will be applied first. If a renaming exists
+    % for the name (i.e., the name will be changed to another name) then
+    % ite renaming need not to be applied because actually it is not
+    % applicable anymore.
+    %
 :- pred region_name_to_var_with_both_renamings(string::in, renaming::in,
-	renaming::in, prog_var::out,
-	name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
+    renaming::in, prog_var::out,
+    name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
 
 region_name_to_var_with_both_renamings(Name0, ResurRenaming, IteRenaming,
-		RegVar, !NameToVar, !VarSet, !VarTypes) :-
-	( if	map.search(ResurRenaming, Name0, Name1)
-	  then	Name = Name1
-	  else
-			( if	map.search(IteRenaming, Name0, Name2)
-			  then	Name = Name2
-			  else  Name = Name0
-			)
-	),
-	region_name_to_var(Name, RegVar, !NameToVar, !VarSet, !VarTypes). 
-
-	% The same as region_name_to_var, but the region name here is 
-	% subjected to resurrection renaming in advance.
-	%
+        RegVar, !NameToVar, !VarSet, !VarTypes) :-
+    ( if    map.search(ResurRenaming, Name0, Name1)
+      then  Name = Name1
+      else
+            ( if    map.search(IteRenaming, Name0, Name2)
+              then  Name = Name2
+              else  Name = Name0
+            )
+    ),
+    region_name_to_var(Name, RegVar, !NameToVar, !VarSet, !VarTypes). 
+
+    % The same as region_name_to_var, but the region name here is 
+    % subjected to resurrection renaming in advance.
+    %
 :- pred region_name_to_var_with_renaming(string::in, renaming::in,
-	prog_var::out, name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
+    prog_var::out, name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.
 
 region_name_to_var_with_renaming(Name0, ResurRenaming, RegVar,
-		!NameToVar, !VarSet, !VarTypes) :-
-	( if	map.search(ResurRenaming, Name0, Name1)
-	  then	Name = Name1
-	  else	Name = Name0
-	),
-	region_name_to_var(Name, RegVar, !NameToVar, !VarSet, !VarTypes). 
-
-:- func make_region_type = mer_type.
-
-make_region_type = RegionType :-
-	RegionTypeName = qualified(mercury_region_builtin_module, "region"),
-	RegionType = defined_type(RegionTypeName, [], kind_star).
-
-	% Instruction is of the form: "Tx: xxxxxx R..."
-	% The first x is the number of the rule, which is not important here.
-	% The next 6 x is either "remove" or "create", the last part is the
-	% region name. This region name will be subjected to renaming due to 
-	% if-then-else and region resurrection.
-	% This predicate turns such an instruction into a call to a suitable
-	% region builtin.
-	% XXX  This is temporary. Using string to represent region instructions
-	% (create, remove, renaming, maybe some more in the future) is not good.
-	% Region instruction should become a specific type with distinct 
-	% constructor for each kind of instruction.
-	% XXX  Call to generate_simple_call here seems overkilled because we
-	% will recompute nonlocals, instmap delta anyway.
-	%
+        !NameToVar, !VarSet, !VarTypes) :-
+    ( if    map.search(ResurRenaming, Name0, Name1)
+      then  Name = Name1
+      else  Name = Name0
+    ),
+    region_name_to_var(Name, RegVar, !NameToVar, !VarSet, !VarTypes). 
+
+    % The region name in a region instruction is subjected to renaming due
+    % to if-then-else and region resurrection. This predicate turns such an
+    % instruction into a call to a suitable region builtin.
+    % XXX  Call to generate_simple_call here seems overkilled because we
+    % will recompute nonlocals, instmap delta anyway.
+    %
 :- pred region_instruction_to_conj(module_info::in, term.context::in,
-	renaming::in, renaming::in, string::in,
-	name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out,
-	hlds_goals::in, hlds_goals::out) is det.
+    renaming::in, renaming::in, region_instruction::in,
+    name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out,
+    hlds_goals::in, hlds_goals::out) is det.
 
 region_instruction_to_conj(ModuleInfo, Context, ResurRenaming, IteRenaming,
-		Instruction, !NameToVar, !VarSet, !VarTypes, Conjs0, Conjs) :-
-	string.substring(Instruction, 4, 6, Kind),
-	string.substring(Instruction, 11, string.length(Instruction) - 11,
-		RegionName),
-	region_name_to_var_with_both_renamings(RegionName, ResurRenaming,
-		IteRenaming, RegVar, !NameToVar, !VarSet, !VarTypes),
-	(	Kind = "create" ->
-		generate_simple_call(mercury_region_builtin_module,
-			"create_region", pf_predicate, only_mode, detism_det,
-			purity_impure, [RegVar], [], [],
-			ModuleInfo, Context, CallGoal)
-	;
-		Kind = "remove"
-	->
-		generate_simple_call(mercury_region_builtin_module,
-			"remove_region", pf_predicate, only_mode, detism_det,
-			purity_impure, [RegVar], [], [],
-			ModuleInfo, Context, CallGoal)
-	;
-		unexpected(this_file, "region_instruction_to_conj: " ++
-			"encounter unknown region instruction")
-	),
-	Conjs = Conjs0 ++ [CallGoal].
-
-	% A resurrection renaming annotation is in the form Rx = Rx_resur_y,
-	% where Rx is the original name of the region, the other is the one 
-	% the region is renamed to.
-	% This predicate converts the anotation into an assigment unification.
-	% The original name of the region is subjected to the renaming due to
-	% if-then-else, if such a renaming exists at the current program point.
-	%
-:- pred resur_renaming_annotation_to_assignment(renaming::in, string::in,
-	name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out,
-	hlds_goals::in, hlds_goals::out) is det.
+        RegionInstruction, !NameToVar, !VarSet, !VarTypes, Conjs0, Conjs) :-
+    (
+        RegionInstruction = create_region(RegionName),
+        region_name_to_var_with_both_renamings(RegionName, ResurRenaming,
+            IteRenaming, RegionVar, !NameToVar, !VarSet, !VarTypes),
+        generate_simple_call(mercury_region_builtin_module,
+            "create_region", pf_predicate, only_mode, detism_det,
+            purity_impure, [RegionVar], [], [],
+            ModuleInfo, Context, CallGoal)
+    ;
+        RegionInstruction = remove_region(RegionName),
+        region_name_to_var_with_both_renamings(RegionName, ResurRenaming,
+            IteRenaming, RegionVar, !NameToVar, !VarSet, !VarTypes),
+        generate_simple_call(mercury_region_builtin_module,
+            "remove_region", pf_predicate, only_mode, detism_det,
+            purity_impure, [RegionVar], [], [],
+            ModuleInfo, Context, CallGoal)
+    ;
+        RegionInstruction = rename_region(_, _),
+        unexpected(this_file, "region_instruction_to_conj: " ++
+            "encounter neither create or remove instruction")
+    ),
+    Conjs = Conjs0 ++ [CallGoal].
+
+    % A resurrection renaming annotation is in the form Rx = Rx_resur_y,
+    % where Rx is the original name of the region, the other is the one 
+    % the region is renamed to.
+    % This predicate converts the anotation into an assigment unification.
+    % The original name of the region is subjected to the renaming due to
+    % if-then-else, if such a renaming exists at the current program point.
+    %
+:- pred resur_renaming_annotation_to_assignment(renaming::in,
+    region_instruction::in, name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out,
+    hlds_goals::in, hlds_goals::out) is det.
 
 resur_renaming_annotation_to_assignment(IteRenaming, Annotation,
-		!NameToVar, !VarSet, !VarTypes, Conjs0, Conjs) :-
-	( if	string.sub_string_search(Annotation, "=", Index)
-	  then
-			Left = string.substring(Annotation, 0, Index - 1),
-			Right = string.substring(Annotation, Index + 2, 
-				string.length(Annotation) - (Index + 2)),
-			% Only the left region needs to be renamed. Ite renaming
-			% does not involve one on the right side.
-			region_name_to_var_with_renaming(Left, IteRenaming,
-				LeftRegVar, !NameToVar, !VarSet, !VarTypes),
-			region_name_to_var(Right, RightRegVar, !NameToVar,
-				!VarSet, !VarTypes),
-			make_assignment_goal(LeftRegVar, RightRegVar,
-				"resurrection renaming annotation",
-				AssignmentGoal),
-			Conjs = Conjs0 ++ [AssignmentGoal]
-	  else
-			unexpected(this_file, "resur_renaming_annotation_to_assignment: "
-				++ "annotation is not assigment")
-	).
-
-	% This predicate turns a renaming annotation due to if-then-else into
-	% an assignment. No renaming needs to be applied to the 
-	% if-then-else renaming annotations.
-	%
-:- pred ite_renaming_annotation_to_assignment(string::in,
-	name_to_prog_var::in, name_to_prog_var::out,
-	prog_varset::in, prog_varset::out, vartypes::in, vartypes::out,
-	hlds_goals::in, hlds_goals::out) is det.
+        !NameToVar, !VarSet, !VarTypes, Conjs0, Conjs) :-
+    (
+        ( Annotation = create_region(_)
+        ; Annotation = remove_region(_)
+        ),
+        unexpected(this_file, "resur_renaming_annotation_to_assignment: "
+            ++ "annotation is not assigment")
+    ;
+        Annotation = rename_region(Right, Left),
+        % Only the left region needs to be renamed. Ite renaming does not
+        % involve the region on the right side.
+        region_name_to_var_with_renaming(Left, IteRenaming, LeftRegVar,
+            !NameToVar, !VarSet, !VarTypes),
+        region_name_to_var(Right, RightRegVar, !NameToVar, !VarSet,
+            !VarTypes),
+        make_assignment_goal(LeftRegVar, RightRegVar,
+            "resurrection renaming annotation", AssignmentGoal),
+        Conjs = Conjs0 ++ [AssignmentGoal]
+    ).
+
+    % This predicate turns a renaming annotation due to if-then-else into
+    % an assignment. No renaming needs to be applied to the 
+    % if-then-else renaming annotations.
+    %
+:- pred ite_renaming_annotation_to_assignment(region_instruction::in,
+    name_to_prog_var::in, name_to_prog_var::out,
+    prog_varset::in, prog_varset::out, vartypes::in, vartypes::out,
+    hlds_goals::in, hlds_goals::out) is det.
 
 ite_renaming_annotation_to_assignment(Annotation, !NameToVar,
-		!VarSet, !VarTypes, Conjs0, Conjs) :-
-	( if	string.sub_string_search(Annotation, "=", Index)
-	  then
-			Left = string.substring(Annotation, 0, Index - 1),
-			Right = string.substring(Annotation, Index + 2, 
-				string.length(Annotation) - (Index + 2)),
-			region_name_to_var(Left, LeftRegVar, !NameToVar,
-				!VarSet, !VarTypes),
-			region_name_to_var(Right, RightRegVar, !NameToVar,
-				!VarSet, !VarTypes),
-			make_assignment_goal(LeftRegVar, RightRegVar,
-				"ite renaming annotation", AssignmentGoal),
-			Conjs = Conjs0 ++ [AssignmentGoal]
-	  else
-			unexpected(this_file, "ite_renaming_annotation_to_assignment: "
-				++ "annotation is not assignment")
-	).
+        !VarSet, !VarTypes, Conjs0, Conjs) :-
+    (
+        ( Annotation = create_region(_)
+        ; Annotation = remove_region(_)
+        ),
+        unexpected(this_file, "ite_renaming_annotation_to_assignment: "
+            ++ "annotation is not assignment")
+    ;
+        Annotation = rename_region(Right, Left),
+        region_name_to_var(Left, LeftRegVar, !NameToVar, !VarSet, !VarTypes),
+        region_name_to_var(Right, RightRegVar, !NameToVar, !VarSet, !VarTypes),
+        make_assignment_goal(LeftRegVar, RightRegVar,
+            "ite renaming annotation", AssignmentGoal),
+        Conjs = Conjs0 ++ [AssignmentGoal]
+    ).
 
 :- pred make_assignment_goal(prog_var::in, prog_var::in, string::in,
-	hlds_goal::out) is det.
+    hlds_goal::out) is det.
 
 make_assignment_goal(LeftRegVar, RightRegVar, Context, AssignmentGoal) :-
-	AssignmentExpr = unify(LeftRegVar, rhs_var(RightRegVar),
-		out_mode - in_mode,
-		assign(LeftRegVar, RightRegVar),
-		unify_context(
-			umc_implicit(Context),
-			[]
-		)
-	),
-	% Nonlocals and instmap delta will be recomputed anyway, so just put
-	% dummy values in.
-	% XXX  We need to setup the instantiationess for LeftRegVar here.
-	% I think it is always recomputed but it seems that I am wrong.
-	% It should be able to be recomputed from the modes in the assigment.
-	% Maybe I am missing or doing something wrong here.
-	NonLocals = set.init,
-	instmap_delta_from_assoc_list([LeftRegVar - ground_inst], InstmapDelta),
-	goal_info_init(NonLocals, InstmapDelta, detism_det, purity_pure,
-		AssignmentInfo),
-	AssignmentGoal = hlds_goal(AssignmentExpr, AssignmentInfo).
+    AssignmentExpr = unify(LeftRegVar, rhs_var(RightRegVar),
+        out_mode - in_mode,
+        assign(LeftRegVar, RightRegVar),
+        unify_context(
+            umc_implicit(Context),
+            []
+        )
+    ),
+    % Nonlocals and instmap delta will be recomputed anyway, so just put
+    % dummy values in.
+    % XXX  We need to setup the instantiationess for LeftRegVar here.
+    % I think it is always recomputed but it seems that I am wrong.
+    % It should be able to be recomputed from the modes in the assigment.
+    % Maybe I am missing or doing something wrong here.
+    NonLocals = set.init,
+    instmap_delta_from_assoc_list([LeftRegVar - ground_inst], InstmapDelta),
+    goal_info_init(NonLocals, InstmapDelta, detism_det, purity_pure,
+        AssignmentInfo),
+    AssignmentGoal = hlds_goal(AssignmentExpr, AssignmentInfo).
 
 %-----------------------------------------------------------------------------%
 %
@@ -965,23 +948,23 @@
 %
 
 :- pred update_instmap_delta_pred(pred_id::in, module_info::in,
-	module_info::out) is det.
-	
+    module_info::out) is det.
+    
 update_instmap_delta_pred(PredId, !ModuleInfo) :-
     module_info_pred_info(!.ModuleInfo, PredId, PredInfo),
     ProcIds = pred_info_non_imported_procids(PredInfo),
     list.foldl(update_instmap_delta_proc(PredId), ProcIds, !ModuleInfo).
 
 :- pred update_instmap_delta_proc(pred_id::in, proc_id::in, 
-	module_info::in, module_info::out) is det.
+    module_info::in, module_info::out) is det.
 
 update_instmap_delta_proc(PredId, ProcId, !ModuleInfo) :-
-	PPId = proc(PredId, ProcId),
-	module_info_pred_proc_info(!.ModuleInfo, PPId, PredInfo, ProcInfo0),
-	RecomputeAtomic = yes,
-	recompute_instmap_delta_proc(RecomputeAtomic, ProcInfo0, ProcInfo,
-		!ModuleInfo),
-	module_info_set_pred_proc_info(PPId, PredInfo, ProcInfo, !ModuleInfo).
+    PPId = proc(PredId, ProcId),
+    module_info_pred_proc_info(!.ModuleInfo, PPId, PredInfo, ProcInfo0),
+    RecomputeAtomic = yes,
+    recompute_instmap_delta_proc(RecomputeAtomic, ProcInfo0, ProcInfo,
+        !ModuleInfo),
+    module_info_set_pred_proc_info(PPId, PredInfo, ProcInfo, !ModuleInfo).
 
 %-----------------------------------------------------------------------------%
 %
@@ -989,28 +972,28 @@
 %
 
 :- pred recheck_purity_pred(pred_id::in, module_info::in,
-	module_info::out) is det.
+    module_info::out) is det.
 
 recheck_purity_pred(PredId, !ModuleInfo) :-
     module_info_pred_info(!.ModuleInfo, PredId, PredInfo),
     ProcIds = pred_info_non_imported_procids(PredInfo),
-	list.foldl(recheck_purity_proc(PredId), ProcIds, !ModuleInfo).
+    list.foldl(recheck_purity_proc(PredId), ProcIds, !ModuleInfo).
 
-	% Recheck purity of the procedure.
-	% This predicate is only called when all the procedures have been
-	% annotated with region information and recorded. This is necessary
-	% because repuritycheck_proc looks up information
-	% about procedures.
-	%
+    % Recheck purity of the procedure.
+    % This predicate is only called when all the procedures have been
+    % annotated with region information and recorded. This is necessary
+    % because repuritycheck_proc looks up information
+    % about procedures.
+    %
 :- pred recheck_purity_proc(pred_id::in, proc_id::in, module_info::in,
-	module_info::out) is det.
+    module_info::out) is det.
 
 recheck_purity_proc(PredId, ProcId, !ModuleInfo) :- 
-	module_info_pred_info(!.ModuleInfo, PredId, PredInfo0),
-	% Recheck purity of this procedure.
-	PPId = proc(PredId, ProcId),
-	repuritycheck_proc(!.ModuleInfo, PPId, PredInfo0, PredInfo),
-	module_info_set_pred_info(PredId, PredInfo, !ModuleInfo).
+    module_info_pred_info(!.ModuleInfo, PredId, PredInfo0),
+    % Recheck purity of this procedure.
+    PPId = proc(PredId, ProcId),
+    repuritycheck_proc(!.ModuleInfo, PPId, PredInfo0, PredInfo),
+    module_info_set_pred_info(PredId, PredInfo, !ModuleInfo).
 
 %-----------------------------------------------------------------------------%
 
Index: rbmm.condition_renaming.m
===================================================================
RCS file:
/home/mercury/mercury1/repository/mercury/compiler/rbmm.condition_renaming.m,v
retrieving revision 1.3
diff -u -u -r1.3 rbmm.condition_renaming.m
--- rbmm.condition_renaming.m	6 Jul 2007 02:35:22 -0000	1.3
+++ rbmm.condition_renaming.m	19 Jul 2007 05:56:03 -0000
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% vim: ft=mercury ts=4 sw=4
+% vim: ft=mercury ts=4 sw=4 et
 %-----------------------------------------------------------------------------%
 % Copyright (C) 2007 The University of Melbourne.
 % This file may only be copied under the terms of the GNU General
@@ -48,71 +48,71 @@
 %-----------------------------------------------------------------------------%
 
 :- type proc_goal_path_regions_table ==
-	map(pred_proc_id, goal_path_regions_table).
+    map(pred_proc_id, goal_path_regions_table).
 :- type goal_path_regions_table == map(goal_path, set(string)).
 
-	% This predicate collects two pieces of information.
-	% 1. The non-local regions of if-then-elses.
-	%		A region is non-local to an if-then-else if the region
-	%		is created in the if-then-else and outlives the scope
-	%		of the if-then-else.
-	% 2. The regions which are created (get bound) in the condition
-	% goals of if-then-else.
-	% We will only store information about a procedure if the information
-	% exists. That means, for example, there is no entry which maps a PPId
-	% to empty.
-	%
-	% This information is used to compute the regions which need to be 
-	% renamed, i.e., both non-local and created in the condition of an
-	% if-then-else.
-	%
+    % This predicate collects two pieces of information.
+    % 1. The non-local regions of if-then-elses.
+    %       A region is non-local to an if-then-else if the region
+    %       is created in the if-then-else and outlives the scope
+    %       of the if-then-else.
+    % 2. The regions which are created (get bound) in the condition
+    % goals of if-then-else.
+    % We will only store information about a procedure if the information
+    % exists. That means, for example, there is no entry which maps a PPId
+    % to empty.
+    %
+    % This information is used to compute the regions which need to be 
+    % renamed, i.e., both non-local and created in the condition of an
+    % if-then-else.
+    %
 :- pred collect_non_local_and_in_cond_regions(module_info::in,
-	rpta_info_table::in, proc_pp_region_set_table::in,
-	proc_pp_region_set_table::in, renaming_table::in, 
-	renaming_annotation_table::in, proc_goal_path_regions_table::out,
-	proc_goal_path_regions_table::out) is det.
-
-	% After having the 2 pieces of information calculated above, this step
-	% is simple. The only thing to note here is that we will only store
-	% information for a procedure when the information exists.
-	% This means that a procedure in which no renaming is required will not
-	% be in the resulting table.
-	%
+    rpta_info_table::in, proc_pp_region_set_table::in,
+    proc_pp_region_set_table::in, renaming_table::in, 
+    renaming_annotation_table::in, proc_goal_path_regions_table::out,
+    proc_goal_path_regions_table::out) is det.
+
+    % After having the 2 pieces of information calculated above, this step
+    % is simple. The only thing to note here is that we will only store
+    % information for a procedure when the information exists.
+    % This means that a procedure in which no renaming is required will not
+    % be in the resulting table.
+    %
 :- pred collect_ite_renamed_regions(proc_goal_path_regions_table::in,
-	proc_goal_path_regions_table::in, proc_goal_path_regions_table::out)
-	is det.
+    proc_goal_path_regions_table::in, proc_goal_path_regions_table::out)
+    is det.
 
-	% This predicate ONLY traverses the procedures which requires
-	% condition renaming and for each condition goal in such a procedure
-	% it introduces the necessary renamings.
-	% The renaming information is stored in the form:
-	% a program point (in the condition goal) --> necessary renaming at
-	% the point.
-	% A new name for a region (variable) at a program point is:
-	% RegionName_ite_Number, where Number is the number of condition goals
-	% to which the program point belongs.
-	%
+    % This predicate ONLY traverses the procedures which requires
+    % condition renaming and for each condition goal in such a procedure
+    % it introduces the necessary renamings.
+    % The renaming information is stored in the form:
+    % a program point (in the condition goal) --> necessary renaming at
+    % the point.
+    % A new name for a region (variable) at a program point is:
+    % RegionName_ite_Number, where Number is the number of condition goals
+    % to which the program point belongs.
+    %
 :- pred collect_ite_renaming(module_info::in, rpta_info_table::in,
-	proc_goal_path_regions_table::in, renaming_table::out) is det.
+    proc_goal_path_regions_table::in, renaming_table::out) is det.
 
-	% In the then branch of an if-then-else in which renaming happens we 
-	% need to introduce reverse renaming annotation in the form of
-	% assignments, e.g., if R is renamed to R_ite_1 in the condition
-	% then we add R = R_ite_1 in the then branch.
-	% Because the if-then-else can lie inside the condition goals of
-	% other if-then-elses, we need to apply the renaming at the 
-	% program point where the annotation is attached.
-	% E.g., At the point renaming R --> R_ite_2 exists, then the
-	% added annotation is R_ite_2 = R_ite_1.
-	%
-	% This predicate will also traverse only procedures in which renaming
-	% happens. For each Condition where renaming happens,
-	% it finds the first program point in the corresponding Then and
-	% introduces the reverse renaming annotation before that ponit.
-	%
+    % In the then branch of an if-then-else in which renaming happens we 
+    % need to introduce reverse renaming annotation in the form of
+    % assignments, e.g., if R is renamed to R_ite_1 in the condition
+    % then we add R = R_ite_1 in the then branch.
+    % Because the if-then-else can lie inside the condition goals of
+    % other if-then-elses, we need to apply the renaming at the 
+    % program point where the annotation is attached.
+    % E.g., At the point renaming R --> R_ite_2 exists, then the
+    % added annotation is R_ite_2 = R_ite_1.
+    %
+    % This predicate will also traverse only procedures in which renaming
+    % happens. For each Condition where renaming happens,
+    % it finds the first program point in the corresponding Then and
+    % introduces the reverse renaming annotation before that ponit.
+    %
 :- pred collect_ite_annotation(proc_goal_path_regions_table::in,
-	execution_path_table::in, rpta_info_table::in, renaming_table::in,
-	renaming_annotation_table::out) is det.
+    execution_path_table::in, rpta_info_table::in, renaming_table::in,
+    renaming_annotation_table::out) is det.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -137,395 +137,390 @@
 %-----------------------------------------------------------------------------%
 
 collect_non_local_and_in_cond_regions(ModuleInfo, RptaInfoTable,
-		LRBeforeTable, LRAfterTable, ResurRenamingTable,
-		ResurRenamingAnnoTable, NonLocalRegionsTable, InCondRegionsTable) :-
+        LRBeforeTable, LRAfterTable, ResurRenamingTable,
+        ResurRenamingAnnoTable, NonLocalRegionsTable, InCondRegionsTable) :-
     module_info_predids(PredIds, ModuleInfo, _),
     list.foldl2(collect_non_local_and_in_cond_regions_pred(ModuleInfo,
-		RptaInfoTable, LRBeforeTable, LRAfterTable, ResurRenamingTable,
-		ResurRenamingAnnoTable), PredIds,
-		map.init, NonLocalRegionsTable, map.init, InCondRegionsTable).
+        RptaInfoTable, LRBeforeTable, LRAfterTable, ResurRenamingTable,
+        ResurRenamingAnnoTable), PredIds,
+        map.init, NonLocalRegionsTable, map.init, InCondRegionsTable).
 
 :- pred collect_non_local_and_in_cond_regions_pred(module_info::in,
-	rpta_info_table::in, proc_pp_region_set_table::in,
-	proc_pp_region_set_table::in, renaming_table::in,
-	renaming_annotation_table::in, pred_id::in,
-	proc_goal_path_regions_table::in, proc_goal_path_regions_table::out,
-	proc_goal_path_regions_table::in, proc_goal_path_regions_table::out)
-	is det.
+    rpta_info_table::in, proc_pp_region_set_table::in,
+    proc_pp_region_set_table::in, renaming_table::in,
+    renaming_annotation_table::in, pred_id::in,
+    proc_goal_path_regions_table::in, proc_goal_path_regions_table::out,
+    proc_goal_path_regions_table::in, proc_goal_path_regions_table::out)
+    is det.
 
 collect_non_local_and_in_cond_regions_pred(ModuleInfo, RptaInfoTable,
-		LRBeforeTable, LRAfterTable, ResurRenamingTable,
-		ResurRenamingAnnoTable, PredId, !NonLocalRegionsTable,
-		!InCondRegionsTable) :-
+        LRBeforeTable, LRAfterTable, ResurRenamingTable,
+        ResurRenamingAnnoTable, PredId, !NonLocalRegionsTable,
+        !InCondRegionsTable) :-
     module_info_pred_info(ModuleInfo, PredId, PredInfo),
     ProcIds = pred_info_non_imported_procids(PredInfo),
     list.foldl2(collect_non_local_and_in_cond_regions_proc(ModuleInfo,
-		PredId, RptaInfoTable, LRBeforeTable, LRAfterTable,
-		ResurRenamingTable, ResurRenamingAnnoTable), ProcIds,
-		!NonLocalRegionsTable, !InCondRegionsTable).
+        PredId, RptaInfoTable, LRBeforeTable, LRAfterTable,
+        ResurRenamingTable, ResurRenamingAnnoTable), ProcIds,
+        !NonLocalRegionsTable, !InCondRegionsTable).
 
 :- pred collect_non_local_and_in_cond_regions_proc(module_info::in,
-	pred_id::in, rpta_info_table::in, proc_pp_region_set_table::in,
-	proc_pp_region_set_table::in, renaming_table::in,
-	renaming_annotation_table::in, proc_id::in,
-	proc_goal_path_regions_table::in, proc_goal_path_regions_table::out,
-	proc_goal_path_regions_table::in, proc_goal_path_regions_table::out)
-	is det.
+    pred_id::in, rpta_info_table::in, proc_pp_region_set_table::in,
+    proc_pp_region_set_table::in, renaming_table::in,
+    renaming_annotation_table::in, proc_id::in,
+    proc_goal_path_regions_table::in, proc_goal_path_regions_table::out,
+    proc_goal_path_regions_table::in, proc_goal_path_regions_table::out)
+    is det.
 
 collect_non_local_and_in_cond_regions_proc(ModuleInfo, PredId,
-		RptaInfoTable, LRBeforeTable, LRAfterTable, ResurRenamingTable,
-		ResurRenamingAnnoTable, ProcId,
-		!NonLocalRegionsTable, !InCondRegionsTable) :-
+        RptaInfoTable, LRBeforeTable, LRAfterTable, ResurRenamingTable,
+        ResurRenamingAnnoTable, ProcId,
+        !NonLocalRegionsTable, !InCondRegionsTable) :-
     PPId = proc(PredId, ProcId),
     ( if    some_are_special_preds([PPId], ModuleInfo)
       then  true
       else
             module_info_proc_info(ModuleInfo, PPId, ProcInfo0),
-			fill_goal_path_slots(ModuleInfo, ProcInfo0, ProcInfo),
+            fill_goal_path_slots(ModuleInfo, ProcInfo0, ProcInfo),
             proc_info_get_goal(ProcInfo, Goal),
-			map.lookup(RptaInfoTable, PPId, rpta_info(Graph, _)),
-			map.lookup(LRBeforeTable, PPId, LRBeforeProc),
-			map.lookup(LRAfterTable, PPId, LRAfterProc),
-			( if	map.search(ResurRenamingTable, PPId,
-						ResurRenamingProc0)
-			  then	ResurRenamingProc = ResurRenamingProc0
-			  else	ResurRenamingProc = map.init
-			),
-			( if 	map.search(ResurRenamingAnnoTable, PPId,
-						ResurRenamingAnnoProc0)
-			  then	ResurRenamingAnnoProc = ResurRenamingAnnoProc0
-			  else	ResurRenamingAnnoProc = map.init
-			),
+            map.lookup(RptaInfoTable, PPId, rpta_info(Graph, _)),
+            map.lookup(LRBeforeTable, PPId, LRBeforeProc),
+            map.lookup(LRAfterTable, PPId, LRAfterProc),
+            ( if    map.search(ResurRenamingTable, PPId,
+                        ResurRenamingProc0)
+              then  ResurRenamingProc = ResurRenamingProc0
+              else  ResurRenamingProc = map.init
+            ),
+            ( if    map.search(ResurRenamingAnnoTable, PPId,
+                        ResurRenamingAnnoProc0)
+              then  ResurRenamingAnnoProc = ResurRenamingAnnoProc0
+              else  ResurRenamingAnnoProc = map.init
+            ),
             collect_non_local_and_in_cond_regions_goal(Graph,
-				LRBeforeProc, LRAfterProc, ResurRenamingProc,
-				ResurRenamingAnnoProc, Goal,
-				map.init, NonLocalRegionsProc,
-				map.init, InCondRegionsProc),
-			( if	map.count(NonLocalRegionsProc) = 0
-			  then	true
-			  else	svmap.set(PPId, NonLocalRegionsProc,
-						!NonLocalRegionsTable)
-			),
-			( if	map.count(InCondRegionsProc) = 0
-			  then	true
-			  else	svmap.set(PPId, InCondRegionsProc,
-						!InCondRegionsTable)
-			)
+                LRBeforeProc, LRAfterProc, ResurRenamingProc,
+                ResurRenamingAnnoProc, Goal,
+                map.init, NonLocalRegionsProc,
+                map.init, InCondRegionsProc),
+            ( if    map.count(NonLocalRegionsProc) = 0
+              then  true
+              else  svmap.set(PPId, NonLocalRegionsProc,
+                        !NonLocalRegionsTable)
+            ),
+            ( if    map.count(InCondRegionsProc) = 0
+              then  true
+              else  svmap.set(PPId, InCondRegionsProc,
+                        !InCondRegionsTable)
+            )
     ).
 
 :- pred collect_non_local_and_in_cond_regions_goal(rpt_graph::in,
-	pp_region_set_table::in, pp_region_set_table::in,
-	renaming_proc::in, renaming_annotation_proc::in, hlds_goal::in,
+    pp_region_set_table::in, pp_region_set_table::in,
+    renaming_proc::in, renaming_annotation_proc::in, hlds_goal::in,
     goal_path_regions_table::in, goal_path_regions_table::out,
-	goal_path_regions_table::in, goal_path_regions_table::out) is det.
+    goal_path_regions_table::in, goal_path_regions_table::out) is det.
 
 collect_non_local_and_in_cond_regions_goal(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc, Goal,
-		!NonLocalRegionsProc, !InCondRegionsProc) :- 
-	Goal = hlds_goal(Expr, _),
-	collect_non_local_and_in_cond_regions_expr(Graph, LRBeforeProc,
-		LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc, Expr,
-		!NonLocalRegionsProc, !InCondRegionsProc).
+        ResurRenamingProc, ResurRenamingAnnoProc, Goal,
+        !NonLocalRegionsProc, !InCondRegionsProc) :- 
+    Goal = hlds_goal(Expr, _),
+    collect_non_local_and_in_cond_regions_expr(Graph, LRBeforeProc,
+        LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc, Expr,
+        !NonLocalRegionsProc, !InCondRegionsProc).
 
 :- pred collect_non_local_and_in_cond_regions_expr(rpt_graph::in,
-	pp_region_set_table::in, pp_region_set_table::in,
-	renaming_proc::in, renaming_annotation_proc::in, hlds_goal_expr::in,
-	goal_path_regions_table::in, goal_path_regions_table::out,
-	goal_path_regions_table::in, goal_path_regions_table::out) is det.
+    pp_region_set_table::in, pp_region_set_table::in,
+    renaming_proc::in, renaming_annotation_proc::in, hlds_goal_expr::in,
+    goal_path_regions_table::in, goal_path_regions_table::out,
+    goal_path_regions_table::in, goal_path_regions_table::out) is det.
 
 collect_non_local_and_in_cond_regions_expr(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc, conj(_, Conjs),
-		!NonLocalRegionsProc, !InCondRegionsProc) :- 
+        ResurRenamingProc, ResurRenamingAnnoProc, conj(_, Conjs),
+        !NonLocalRegionsProc, !InCondRegionsProc) :- 
     list.foldl2(collect_non_local_and_in_cond_regions_goal(Graph,
-					LRBeforeProc, LRAfterProc,
-					ResurRenamingProc,
-					ResurRenamingAnnoProc),
-		Conjs, !NonLocalRegionsProc, !InCondRegionsProc). 
+                    LRBeforeProc, LRAfterProc,
+                    ResurRenamingProc,
+                    ResurRenamingAnnoProc),
+        Conjs, !NonLocalRegionsProc, !InCondRegionsProc). 
 
 collect_non_local_and_in_cond_regions_expr(_, _, _, _, _,
-		plain_call(_, _, _, _, _, _),
-		!NonLocalRegionsProc, !InCondRegionsProc).
+        plain_call(_, _, _, _, _, _),
+        !NonLocalRegionsProc, !InCondRegionsProc).
 collect_non_local_and_in_cond_regions_expr(_, _, _, _, _,
-		generic_call(_, _, _, _),
-		!NonLocalRegionsProc, !InCondRegionsProc).
+        generic_call(_, _, _, _),
+        !NonLocalRegionsProc, !InCondRegionsProc).
 collect_non_local_and_in_cond_regions_expr(_, _, _, _, _,
-		call_foreign_proc(_, _, _, _, _, _, _),
-		!NonLocalRegionsProc, !InCondRegionsProc).
+        call_foreign_proc(_, _, _, _, _, _, _),
+        !NonLocalRegionsProc, !InCondRegionsProc).
 
 collect_non_local_and_in_cond_regions_expr(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc, switch(_, _, Cases),
-		!NonLocalRegionsProc, !InCondRegionsProc) :- 
+        ResurRenamingProc, ResurRenamingAnnoProc, switch(_, _, Cases),
+        !NonLocalRegionsProc, !InCondRegionsProc) :- 
     list.foldl2(collect_non_local_and_in_cond_regions_case(Graph,
-					LRBeforeProc, LRAfterProc,
-					ResurRenamingProc,
-					ResurRenamingAnnoProc),
-		Cases, !NonLocalRegionsProc, !InCondRegionsProc).
+                    LRBeforeProc, LRAfterProc,
+                    ResurRenamingProc,
+                    ResurRenamingAnnoProc),
+        Cases, !NonLocalRegionsProc, !InCondRegionsProc).
 collect_non_local_and_in_cond_regions_expr(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc, disj(Disjs),
-		!NonLocalRegionsProc, !InCondRegionsProc) :-
+        ResurRenamingProc, ResurRenamingAnnoProc, disj(Disjs),
+        !NonLocalRegionsProc, !InCondRegionsProc) :-
     list.foldl2(collect_non_local_and_in_cond_regions_goal(Graph,
-					LRBeforeProc, LRAfterProc,
-					ResurRenamingProc,
-					ResurRenamingAnnoProc),
-		Disjs, !NonLocalRegionsProc, !InCondRegionsProc). 
+                    LRBeforeProc, LRAfterProc,
+                    ResurRenamingProc,
+                    ResurRenamingAnnoProc),
+        Disjs, !NonLocalRegionsProc, !InCondRegionsProc). 
 collect_non_local_and_in_cond_regions_expr(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc, negation(Goal),
-		!NonLocalRegionsProc, !InCondRegionsProc) :- 
+        ResurRenamingProc, ResurRenamingAnnoProc, negation(Goal),
+        !NonLocalRegionsProc, !InCondRegionsProc) :- 
     collect_non_local_and_in_cond_regions_goal(Graph, LRBeforeProc,
-		LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc, Goal,
-		!NonLocalRegionsProc, !InCondRegionsProc). 
+        LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc, Goal,
+        !NonLocalRegionsProc, !InCondRegionsProc). 
 collect_non_local_and_in_cond_regions_expr(_, _, _, _, _,
-		unify(_, _, _, _, _), !NonLocalRegionsProc, !InCondRegionsProc).
+        unify(_, _, _, _, _), !NonLocalRegionsProc, !InCondRegionsProc).
 
 collect_non_local_and_in_cond_regions_expr(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc, scope(_, Goal),
-		!NonLocalRegionsProc, !InCondRegionsProc) :- 
-	collect_non_local_and_in_cond_regions_goal(Graph, LRBeforeProc,
-		LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc, Goal,
-		!NonLocalRegionsProc, !InCondRegionsProc).
+        ResurRenamingProc, ResurRenamingAnnoProc, scope(_, Goal),
+        !NonLocalRegionsProc, !InCondRegionsProc) :- 
+    collect_non_local_and_in_cond_regions_goal(Graph, LRBeforeProc,
+        LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc, Goal,
+        !NonLocalRegionsProc, !InCondRegionsProc).
 
 collect_non_local_and_in_cond_regions_expr(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc, Expr,
-		!NonLocalRegionProc, !InCondRegionsProc) :- 
-	Expr = if_then_else(_, Cond, Then, Else),
-
-	% We only care about regions created inside condition goals.
-	collect_regions_created_in_condition(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc, Cond,
-		!InCondRegionsProc),
-
-	% The sets of non_local regions in the (Cond, Then) and in the (Else)
-	% branch are the same, therefore we will only calculate in one of them.
-	% As it is here, we calculate for (Else) with the hope that it is
-	% usually more efficient (only Else compared to both Cond and Then).
+        ResurRenamingProc, ResurRenamingAnnoProc, Expr,
+        !NonLocalRegionProc, !InCondRegionsProc) :- 
+    Expr = if_then_else(_, Cond, Then, Else),
+
+    % We only care about regions created inside condition goals.
+    collect_regions_created_in_condition(Graph, LRBeforeProc, LRAfterProc,
+        ResurRenamingProc, ResurRenamingAnnoProc, Cond,
+        !InCondRegionsProc),
+
+    % The sets of non_local regions in the (Cond, Then) and in the (Else)
+    % branch are the same, therefore we will only calculate in one of them.
+    % As it is here, we calculate for (Else) with the hope that it is
+    % usually more efficient (only Else compared to both Cond and Then).
     collect_non_local_and_in_cond_regions_goal(Graph, LRBeforeProc,
-		LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
-		Cond, !NonLocalRegionProc, !InCondRegionsProc),
+        LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
+        Cond, !NonLocalRegionProc, !InCondRegionsProc),
     collect_non_local_and_in_cond_regions_goal(Graph, LRBeforeProc,
-		LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
-		Then, !NonLocalRegionProc, !InCondRegionsProc),
+        LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
+        Then, !NonLocalRegionProc, !InCondRegionsProc),
     collect_non_local_regions_in_ite(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc, Else,
-		!NonLocalRegionProc).
+        ResurRenamingProc, ResurRenamingAnnoProc, Else,
+        !NonLocalRegionProc).
 
 collect_non_local_and_in_cond_regions_expr(_, _, _, _, _, shorthand(_),
-		!NonLocalRegionProc, !InCondRegionsProc) :- 
+        !NonLocalRegionProc, !InCondRegionsProc) :- 
     unexpected(this_file, "collect_non_local_and_in_cond_regions_expr: "
-		++ "shorthand not handled").
+        ++ "shorthand not handled").
 
 :- pred collect_non_local_and_in_cond_regions_case(rpt_graph::in,
-	pp_region_set_table::in, pp_region_set_table::in,
-	renaming_proc::in, renaming_annotation_proc::in, case::in,
-	goal_path_regions_table::in, goal_path_regions_table::out,
-	goal_path_regions_table::in, goal_path_regions_table::out) is det.
+    pp_region_set_table::in, pp_region_set_table::in,
+    renaming_proc::in, renaming_annotation_proc::in, case::in,
+    goal_path_regions_table::in, goal_path_regions_table::out,
+    goal_path_regions_table::in, goal_path_regions_table::out) is det.
 
 collect_non_local_and_in_cond_regions_case(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc, Case,
-		!NonLocalRegionProc, !InCondRegionsProc) :-
+        ResurRenamingProc, ResurRenamingAnnoProc, Case,
+        !NonLocalRegionProc, !InCondRegionsProc) :-
     Case = case(_, Goal),
     collect_non_local_and_in_cond_regions_goal(Graph, LRBeforeProc,
-		LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc, Goal,
-		!NonLocalRegionProc, !InCondRegionsProc).
+        LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc, Goal,
+        !NonLocalRegionProc, !InCondRegionsProc).
 
 :- pred collect_non_local_regions_in_ite(rpt_graph::in,
-	pp_region_set_table::in, pp_region_set_table::in, renaming_proc::in,
-	renaming_annotation_proc::in, hlds_goal::in,
-	goal_path_regions_table::in, goal_path_regions_table::out) is det.
+    pp_region_set_table::in, pp_region_set_table::in, renaming_proc::in,
+    renaming_annotation_proc::in, hlds_goal::in,
+    goal_path_regions_table::in, goal_path_regions_table::out) is det.
 
 collect_non_local_regions_in_ite(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc, GoalInIte,
-		!NonLocalRegionProc) :-
-	GoalInIte = hlds_goal(Expr, Info),
-	( if	goal_is_atomic(Expr)
-	  then
-			ProgPoint = program_point_init(Info),
-			ProgPoint = pp(_, GoalPath),
-			map.lookup(LRBeforeProc, ProgPoint, LRBefore),
-			map.lookup(LRAfterProc, ProgPoint, LRAfter),
-			
-			% XXX We may also need VoidVarRegionTable to be
-			% included in RemovedAfter.
-			set.difference(LRBefore, LRAfter, RemovedAfterNodes),
-			set.difference(LRAfter, LRBefore, CreatedBeforeNodes),
-			% Those sets need to subject to resurrection renaming
-			% and annotations.
-			% Apply resurrection renaming to those sets.
-			% For each renaming annotation, the left one is put
-			% into CreatedBefore, and the right one is put into
-			% RemovedAfter.
-			( if	map.search(ResurRenamingProc, ProgPoint,
-						ResurRenaming0)
-			  then	ResurRenaming = ResurRenaming0
-			  else  ResurRenaming = map.init
-			),
-			set.fold(apply_region_renaming(Graph, ResurRenaming),
-				RemovedAfterNodes, set.init,
-				RemovedAfterRegions0),
-			set.fold(apply_region_renaming(Graph, ResurRenaming),
-				CreatedBeforeNodes, set.init,
-				CreatedBeforeRegions0),
-
-			( if	map.search(ResurRenamingAnnoProc, ProgPoint,
-						ResurRenamingAnnos0)
-			  then	ResurRenamingAnnos = ResurRenamingAnnos0
-			  else	ResurRenamingAnnos = []
-			),  
-			list.foldl2(renaming_annotation_to_regions,
-				ResurRenamingAnnos, set.init, LeftRegions,
-				set.init, RightRegions),
-			set.union(RemovedAfterRegions0, RightRegions,
-				RemovedAfterRegions),
-			set.union(CreatedBeforeRegions0, LeftRegions,
-				CreatedBeforeRegions),
-			record_non_local_regions(GoalPath, CreatedBeforeRegions,
-				RemovedAfterRegions, !NonLocalRegionProc)
-	  else
-			collect_non_local_regions_in_ite_compound_goal(Graph,
-				LRBeforeProc, LRAfterProc, ResurRenamingProc,
-				ResurRenamingAnnoProc, GoalInIte,
-				!NonLocalRegionProc)
-	).
+        ResurRenamingProc, ResurRenamingAnnoProc, GoalInIte,
+        !NonLocalRegionProc) :-
+    GoalInIte = hlds_goal(Expr, Info),
+    ( if    goal_is_atomic(Expr)
+      then
+            ProgPoint = program_point_init(Info),
+            ProgPoint = pp(_, GoalPath),
+            map.lookup(LRBeforeProc, ProgPoint, LRBefore),
+            map.lookup(LRAfterProc, ProgPoint, LRAfter),
+            
+            % XXX We may also need VoidVarRegionTable to be
+            % included in RemovedAfter.
+            set.difference(LRBefore, LRAfter, RemovedAfterNodes),
+            set.difference(LRAfter, LRBefore, CreatedBeforeNodes),
+            % Those sets need to subject to resurrection renaming
+            % and annotations.
+            % Apply resurrection renaming to those sets.
+            % For each renaming annotation, the left one is put
+            % into CreatedBefore, and the right one is put into
+            % RemovedAfter.
+            ( if    map.search(ResurRenamingProc, ProgPoint,
+                        ResurRenaming0)
+              then  ResurRenaming = ResurRenaming0
+              else  ResurRenaming = map.init
+            ),
+            set.fold(apply_region_renaming(Graph, ResurRenaming),
+                RemovedAfterNodes, set.init,
+                RemovedAfterRegions0),
+            set.fold(apply_region_renaming(Graph, ResurRenaming),
+                CreatedBeforeNodes, set.init,
+                CreatedBeforeRegions0),
+
+            ( if    map.search(ResurRenamingAnnoProc, ProgPoint,
+                        ResurRenamingAnnos0)
+              then  ResurRenamingAnnos = ResurRenamingAnnos0
+              else  ResurRenamingAnnos = []
+            ),  
+            list.foldl2(renaming_annotation_to_regions,
+                ResurRenamingAnnos, set.init, LeftRegions,
+                set.init, RightRegions),
+            set.union(RemovedAfterRegions0, RightRegions,
+                RemovedAfterRegions),
+            set.union(CreatedBeforeRegions0, LeftRegions,
+                CreatedBeforeRegions),
+            record_non_local_regions(GoalPath, CreatedBeforeRegions,
+                RemovedAfterRegions, !NonLocalRegionProc)
+      else
+            collect_non_local_regions_in_ite_compound_goal(Graph,
+                LRBeforeProc, LRAfterProc, ResurRenamingProc,
+                ResurRenamingAnnoProc, GoalInIte,
+                !NonLocalRegionProc)
+    ).
 
 :- pred apply_region_renaming(rpt_graph::in, renaming::in, rptg_node::in,
-	set(string)::in, set(string)::out) is det.
+    set(string)::in, set(string)::out) is det.
 
 apply_region_renaming(Graph, Renaming, Node, !Regions) :-
-	RegionName = rptg_lookup_region_name(Graph, Node),	
-	( if	map.search(Renaming, RegionName, RenamedRegionName)
-	  then	svset.insert(RenamedRegionName, !Regions)
-	  else	svset.insert(RegionName, !Regions)
-	).
-	  		
-:- pred renaming_annotation_to_regions(string::in,
-	set(string)::in, set(string)::out,
-	set(string)::in, set(string)::out) is det.
+    RegionName = rptg_lookup_region_name(Graph, Node),  
+    ( if    map.search(Renaming, RegionName, RenamedRegionName)
+      then  svset.insert(RenamedRegionName, !Regions)
+      else  svset.insert(RegionName, !Regions)
+    ).
+            
+:- pred renaming_annotation_to_regions(region_instruction::in,
+    set(string)::in, set(string)::out,
+    set(string)::in, set(string)::out) is det.
 
 renaming_annotation_to_regions(RenameAnnotation, !LeftRegions,
-		!RightRegions) :-
-	( if	string.sub_string_search(RenameAnnotation, "=", Index)
-	  then
-	  		LeftRegion = string.substring(RenameAnnotation, 0,
-				Index - 1),
-
-			RightRegion = string.substring(RenameAnnotation,
-				Index + 2,
-				string.length(RenameAnnotation) - (Index + 2)),
-			svset.insert(LeftRegion, !LeftRegions),
-			svset.insert(RightRegion, !RightRegions)
-	  else
-	  		unexpected(this_file, "renaming_annotation_to_regions: "
-				++ "annotation is not assignment")
-	).
-
-	% The non-local regions of an if-then-else will be attached to 
-	% the goal path to the condition.
-	% Non-local regions of an if-then-else are ones that are created
-	% somewhere inside the if-then-else and not be removed inside it
-	% (i.e., outlive the if-then-else's scope).
-	% If a region is created in an if-then-else, it is created
-	% in both (Cond, Then) and (Else) branches. (Of cource one of them
-	% is in effect at runtime). If it is removed in the if-then-else
-	% then it is also removed in both. Therefore it is enough to 
-	% consider either (Cond, Then) or (Else). As said above,
-	% we here choose to calculate for (Else).
-	%
-	% The algorithm is that: at each program point (inside the else),
-	% the non-local set of regions is updated by including the regions
-	% created before or at that program point and excluding those removed
-	% at or after the program point.
-	% Because if-then-else can be nestted, we need to update the
-	% non-local sets of all the surrounding if-then-elses of this
-	% program point.
-	%
+        !RightRegions) :-
+    (
+        ( RenameAnnotation = create_region(_)
+        ; RenameAnnotation = remove_region(_)
+        ),
+        unexpected(this_file, "renaming_annotation_to_regions: "
+            ++ "annotation is not assignment")
+    ;
+        RenameAnnotation = rename_region(RightRegion, LeftRegion),
+        svset.insert(LeftRegion, !LeftRegions),
+        svset.insert(RightRegion, !RightRegions)
+    ).
+
+    % The non-local regions of an if-then-else will be attached to 
+    % the goal path to the condition.
+    % Non-local regions of an if-then-else are ones that are created
+    % somewhere inside the if-then-else and not be removed inside it
+    % (i.e., outlive the if-then-else's scope).
+    % If a region is created in an if-then-else, it is created
+    % in both (Cond, Then) and (Else) branches. (Of cource one of them
+    % is in effect at runtime). If it is removed in the if-then-else
+    % then it is also removed in both. Therefore it is enough to 
+    % consider either (Cond, Then) or (Else). As said above,
+    % we here choose to calculate for (Else).
+    %
+    % The algorithm is that: at each program point (inside the else),
+    % the non-local set of regions is updated by including the regions
+    % created before or at that program point and excluding those removed
+    % at or after the program point.
+    % Because if-then-else can be nestted, we need to update the
+    % non-local sets of all the surrounding if-then-elses of this
+    % program point.
+    %
 :- pred record_non_local_regions(goal_path::in, set(string)::in,
-	set(string)::in, goal_path_regions_table::in,
-	goal_path_regions_table::out) is det.
+    set(string)::in, goal_path_regions_table::in,
+    goal_path_regions_table::out) is det.
 
 record_non_local_regions([], _, _, !NonLocalRegionProc).
 record_non_local_regions(Path, Created, Removed, !NonLocalRegionProc) :-
-	Path = [Step | Steps],
-	(
-		Step = step_ite_else
-	->
-		% The current NonLocalRegions are attached to the goal path to
-		% the corresponding condition.
-		PathToCond = [step_ite_cond | Steps],
-		( if	map.search(!.NonLocalRegionProc, PathToCond,
-					NonLocalRegions0)
-		  then
-				set.union(NonLocalRegions0, Created,
-					NonLocalRegions1),
-				set.difference(NonLocalRegions1, Removed,
-					NonLocalRegions)
-		  else
-				set.difference(Created, Removed,
-					NonLocalRegions)
-		),
-		% Only record if some non-local region(s) exist.
-		( if	set.empty(NonLocalRegions)
-		  then	true
-		  else	svmap.set(PathToCond, NonLocalRegions,
-					!NonLocalRegionProc)
-		)
-	;
-		true
-	),
-
-	% Need to update the non-local sets of outer if-then-elses of this
-	% one, if any.
-	record_non_local_regions(Steps, Created, Removed, !NonLocalRegionProc).
+    Path = [Step | Steps],
+    (
+        Step = step_ite_else
+    ->
+        % The current NonLocalRegions are attached to the goal path to
+        % the corresponding condition.
+        PathToCond = [step_ite_cond | Steps],
+        ( if    map.search(!.NonLocalRegionProc, PathToCond,
+                    NonLocalRegions0)
+          then
+                set.union(NonLocalRegions0, Created,
+                    NonLocalRegions1),
+                set.difference(NonLocalRegions1, Removed,
+                    NonLocalRegions)
+          else  set.difference(Created, Removed, NonLocalRegions)
+        ),
+        % Only record if some non-local region(s) exist.
+        ( if    set.empty(NonLocalRegions)
+          then  true
+          else  svmap.set(PathToCond, NonLocalRegions,
+                    !NonLocalRegionProc)
+        )
+    ;
+        true
+    ),
+
+    % Need to update the non-local sets of outer if-then-elses of this
+    % one, if any.
+    record_non_local_regions(Steps, Created, Removed, !NonLocalRegionProc).
 
 :- pred collect_non_local_regions_in_ite_compound_goal(rpt_graph::in,
-	pp_region_set_table::in, pp_region_set_table::in,
-	renaming_proc::in, renaming_annotation_proc::in, hlds_goal::in,
-	goal_path_regions_table::in, goal_path_regions_table::out) is det.
+    pp_region_set_table::in, pp_region_set_table::in,
+    renaming_proc::in, renaming_annotation_proc::in, hlds_goal::in,
+    goal_path_regions_table::in, goal_path_regions_table::out) is det.
 
 collect_non_local_regions_in_ite_compound_goal(Graph, LRBeforeProc,
-		LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
-		GoalInIte, !NonLocalRegionProc) :-
-	GoalInIte = hlds_goal(Expr, _),
-	(
-		Expr = conj(_, [Conj | Conjs]),
-		list.foldl(collect_non_local_regions_in_ite(Graph, LRBeforeProc,
-						LRAfterProc, ResurRenamingProc,
-						ResurRenamingAnnoProc), 
-			[Conj | Conjs], !NonLocalRegionProc)
-	;
-		Expr = disj([Disj | Disjs]),
-		list.foldl(collect_non_local_regions_in_ite(Graph, LRBeforeProc,
-						LRAfterProc, ResurRenamingProc,
-						ResurRenamingAnnoProc), 
-			[Disj | Disjs], !NonLocalRegionProc)
-	;
-		Expr = switch(_, _, Cases),
-		list.foldl(collect_non_local_regions_in_ite_case(Graph,
-						LRBeforeProc, LRAfterProc,
-						ResurRenamingProc,
-						ResurRenamingAnnoProc),
-			Cases, !NonLocalRegionProc)
-	;
-		Expr = negation(Goal),
-		collect_non_local_regions_in_ite(Graph, LRBeforeProc,
-			LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
-			Goal, !NonLocalRegionProc)
-	;
-		Expr = scope(_, Goal),
-		collect_non_local_regions_in_ite(Graph, LRBeforeProc,
-			LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
-			Goal, !NonLocalRegionProc)
-	;
-		Expr = if_then_else(_, Cond, Then, Else),
-		collect_non_local_regions_in_ite(Graph, LRBeforeProc,
-			LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
-			Cond, !NonLocalRegionProc),
-		collect_non_local_regions_in_ite(Graph, LRBeforeProc,
-			LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
-			Then, !NonLocalRegionProc),
-		collect_non_local_regions_in_ite(Graph, LRBeforeProc,
-			LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
-			Else, !NonLocalRegionProc)
-	;
-		( Expr = unify(_, _, _, _, _) 
+        LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
+        GoalInIte, !NonLocalRegionProc) :-
+    GoalInIte = hlds_goal(Expr, _),
+    (
+        Expr = conj(_, [Conj | Conjs]),
+        list.foldl(collect_non_local_regions_in_ite(Graph, LRBeforeProc,
+                        LRAfterProc, ResurRenamingProc,
+                        ResurRenamingAnnoProc), 
+            [Conj | Conjs], !NonLocalRegionProc)
+    ;
+        Expr = disj([Disj | Disjs]),
+        list.foldl(collect_non_local_regions_in_ite(Graph, LRBeforeProc,
+                        LRAfterProc, ResurRenamingProc,
+                        ResurRenamingAnnoProc), 
+            [Disj | Disjs], !NonLocalRegionProc)
+    ;
+        Expr = switch(_, _, Cases),
+        list.foldl(collect_non_local_regions_in_ite_case(Graph,
+                        LRBeforeProc, LRAfterProc,
+                        ResurRenamingProc,
+                        ResurRenamingAnnoProc),
+            Cases, !NonLocalRegionProc)
+    ;
+        Expr = negation(Goal),
+        collect_non_local_regions_in_ite(Graph, LRBeforeProc,
+            LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
+            Goal, !NonLocalRegionProc)
+    ;
+        Expr = scope(_, Goal),
+        collect_non_local_regions_in_ite(Graph, LRBeforeProc,
+            LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
+            Goal, !NonLocalRegionProc)
+    ;
+        Expr = if_then_else(_, Cond, Then, Else),
+        collect_non_local_regions_in_ite(Graph, LRBeforeProc,
+            LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
+            Cond, !NonLocalRegionProc),
+        collect_non_local_regions_in_ite(Graph, LRBeforeProc,
+            LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
+            Then, !NonLocalRegionProc),
+        collect_non_local_regions_in_ite(Graph, LRBeforeProc,
+            LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc,
+            Else, !NonLocalRegionProc)
+    ;
+        ( Expr = unify(_, _, _, _, _) 
         ; Expr = plain_call(_, _, _, _, _, _) 
         ; Expr = conj(_, [])
         ; Expr = disj([])
@@ -533,22 +528,22 @@
         ; Expr = generic_call(_, _, _, _)
         ; Expr = shorthand(_)
         ),
-		unexpected(this_file,
+        unexpected(this_file,
             "collect_non_local_regions_in_ite_compound_goal: "
-			++ "encountered atomic or unsupported goal")
-	).
+            ++ "encountered atomic or unsupported goal")
+    ).
 
 :- pred collect_non_local_regions_in_ite_case(rpt_graph::in,
-	pp_region_set_table::in, pp_region_set_table::in,
-	renaming_proc::in, renaming_annotation_proc::in, case::in,
-	goal_path_regions_table::in, goal_path_regions_table::out) is det.
-
-collect_non_local_regions_in_ite_case(Graph, LRBeforeProc, LRAfterProc,
ResurRenamingProc, ResurRenamingAnnoProc, Case,
-		!NonLocalRegionProc) :-
-	Case = case(_, Goal),
-	collect_non_local_regions_in_ite(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc, Goal,
-		!NonLocalRegionProc).
+    pp_region_set_table::in, pp_region_set_table::in,
+    renaming_proc::in, renaming_annotation_proc::in, case::in,
+    goal_path_regions_table::in, goal_path_regions_table::out) is det.
+
+collect_non_local_regions_in_ite_case(Graph, LRBeforeProc, LRAfterProc,
+        ResurRenamingProc, ResurRenamingAnnoProc, Case, !NonLocalRegionProc) :-
+    Case = case(_, Goal),
+    collect_non_local_regions_in_ite(Graph, LRBeforeProc, LRAfterProc,
+        ResurRenamingProc, ResurRenamingAnnoProc, Goal,
+        !NonLocalRegionProc).
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -558,141 +553,138 @@
 % Collect regions created inside condition goals of if-then-elses.
 %
 
-	% The process here is very similar to that of
-	% collect_non_local_regions_in_ite predicate.
-	% The difference is that this predicate is used only in the scope of
-	% a condition goal. 
-	%
+    % The process here is very similar to that of
+    % collect_non_local_regions_in_ite predicate.
+    % The difference is that this predicate is used only in the scope of
+    % a condition goal. 
+    %
 :- pred collect_regions_created_in_condition(rpt_graph::in,
-	pp_region_set_table::in, pp_region_set_table::in,
-	renaming_proc::in, renaming_annotation_proc::in, hlds_goal::in,
-	goal_path_regions_table::in, goal_path_regions_table::out) is det.
+    pp_region_set_table::in, pp_region_set_table::in,
+    renaming_proc::in, renaming_annotation_proc::in, hlds_goal::in,
+    goal_path_regions_table::in, goal_path_regions_table::out) is det.
 
 collect_regions_created_in_condition(Graph, LRBeforeProc, LRAfterProc, 
-		ResurRenamingProc, ResurRenamingAnnoProc, Cond,
-		!InCondRegionsProc) :-
-	Cond = hlds_goal(Expr, Info),
-	( if	goal_is_atomic(Expr)
-	  then
-			ProgPoint = program_point_init(Info),
-			ProgPoint = pp(_, GoalPath),
-			map.lookup(LRBeforeProc, ProgPoint, LRBefore),
-			map.lookup(LRAfterProc, ProgPoint, LRAfter),
-			
-			set.difference(LRAfter, LRBefore, CreatedNodes),
-			% We need to apply renaming to this CreatedNodes set
-			% and look up the renaming annotations after this
-			% program point. For each renaming annotation the left
-			% one is created and the right is removed.
-			( if	map.search(ResurRenamingProc, ProgPoint,
-						ResurRenaming0)
-			  then	ResurRenaming = ResurRenaming0
-			  else  ResurRenaming = map.init
-			),
-			set.fold(apply_region_renaming(Graph, ResurRenaming),
-				CreatedNodes, set.init, CreatedRegions0),
-
-			( if	map.search(ResurRenamingAnnoProc, ProgPoint,
-						ResurRenamingAnnos0)
-			  then	ResurRenamingAnnos = ResurRenamingAnnos0
-			  else	ResurRenamingAnnos = []
-			),  
-			list.foldl2(renaming_annotation_to_regions,
-				ResurRenamingAnnos, set.init, LeftRegions,
-				set.init, _RightRegions),
-			set.union(CreatedRegions0, LeftRegions, CreatedRegions),
-		
-			record_regions_created_in_condition(GoalPath,
-				CreatedRegions, !InCondRegionsProc)
-	  else
-			collect_regions_created_in_condition_compound_goal(
-				Graph, LRBeforeProc, LRAfterProc,
-				ResurRenamingProc, ResurRenamingAnnoProc, Cond,
-				!InCondRegionsProc)
-	).
+        ResurRenamingProc, ResurRenamingAnnoProc, Cond, !InCondRegionsProc) :-
+    Cond = hlds_goal(Expr, Info),
+    ( if    goal_is_atomic(Expr)
+      then
+            ProgPoint = program_point_init(Info),
+            ProgPoint = pp(_, GoalPath),
+            map.lookup(LRBeforeProc, ProgPoint, LRBefore),
+            map.lookup(LRAfterProc, ProgPoint, LRAfter),
+            
+            set.difference(LRAfter, LRBefore, CreatedNodes),
+            % We need to apply renaming to this CreatedNodes set
+            % and look up the renaming annotations after this
+            % program point. For each renaming annotation the left
+            % one is created and the right is removed.
+            ( if    map.search(ResurRenamingProc, ProgPoint,
+                        ResurRenaming0)
+              then  ResurRenaming = ResurRenaming0
+              else  ResurRenaming = map.init
+            ),
+            set.fold(apply_region_renaming(Graph, ResurRenaming),
+                CreatedNodes, set.init, CreatedRegions0),
+
+            ( if    map.search(ResurRenamingAnnoProc, ProgPoint,
+                        ResurRenamingAnnos0)
+              then  ResurRenamingAnnos = ResurRenamingAnnos0
+              else  ResurRenamingAnnos = []
+            ),  
+            list.foldl2(renaming_annotation_to_regions,
+                ResurRenamingAnnos, set.init, LeftRegions,
+                set.init, _RightRegions),
+            set.union(CreatedRegions0, LeftRegions, CreatedRegions),
+        
+            record_regions_created_in_condition(GoalPath,
+                CreatedRegions, !InCondRegionsProc)
+      else
+            collect_regions_created_in_condition_compound_goal(
+                Graph, LRBeforeProc, LRAfterProc,
+                ResurRenamingProc, ResurRenamingAnnoProc, Cond,
+                !InCondRegionsProc)
+    ).
  
-	% The regions created inside the condition of an if-then-else will
-	% be attached to the goal path to the condition.
-	%
-	% We need to update the sets of all the conditions surrounding this
-	% program point.
-	%
+    % The regions created inside the condition of an if-then-else will
+    % be attached to the goal path to the condition.
+    %
+    % We need to update the sets of all the conditions surrounding this
+    % program point.
+    %
 :- pred record_regions_created_in_condition(goal_path::in, set(string)::in,
-	goal_path_regions_table::in, goal_path_regions_table::out) is det.
+    goal_path_regions_table::in, goal_path_regions_table::out) is det.
 
 record_regions_created_in_condition([], _, !InCondRegionsProc).
 record_regions_created_in_condition(Path, Created, !InCondRegionsProc) :-
-	Path = [Step | Steps],
-	(
-		Step = step_ite_cond
-	->
-		( if	map.search(!.InCondRegionsProc, Path, InCondRegions0)
-		  then	set.union(InCondRegions0, Created,
-					InCondRegions)
-		  else	InCondRegions = Created
-		),
-		% Only record if the some region(s) is actually created inside
-		% the condition.
-		( if	set.empty(InCondRegions)
-		  then	true
-		  else	svmap.set(Path, InCondRegions, !InCondRegionsProc)
-		)
-	;
-		true
-	),
-	record_regions_created_in_condition(Steps, Created, !InCondRegionsProc).
+    Path = [Step | Steps],
+    ( Step = step_ite_cond  ->
+        ( if    map.search(!.InCondRegionsProc, Path, InCondRegions0)
+          then  set.union(InCondRegions0, Created,
+                    InCondRegions)
+          else  InCondRegions = Created
+        ),
+        % Only record if the some region(s) is actually created inside
+        % the condition.
+        ( if    set.empty(InCondRegions)
+          then  true
+          else  svmap.set(Path, InCondRegions, !InCondRegionsProc)
+        )
+    ;
+        true
+    ),
+    record_regions_created_in_condition(Steps, Created, !InCondRegionsProc).
 
 :- pred collect_regions_created_in_condition_compound_goal(rpt_graph::in,
-	pp_region_set_table::in, pp_region_set_table::in,
-	renaming_proc::in, renaming_annotation_proc::in, hlds_goal::in,
-	goal_path_regions_table::in, goal_path_regions_table::out) is det.
+    pp_region_set_table::in, pp_region_set_table::in,
+    renaming_proc::in, renaming_annotation_proc::in, hlds_goal::in,
+    goal_path_regions_table::in, goal_path_regions_table::out) is det.
 
 collect_regions_created_in_condition_compound_goal(Graph, LRBeforeProc,
-		LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc, GoalInIte,
-		!InCondRegionsProc) :-
-	GoalInIte = hlds_goal(Expr, _),
-	(
-		Expr = conj(_, [Conj | Conjs]),
-		list.foldl(collect_regions_created_in_condition(Graph,
-			LRBeforeProc, LRAfterProc, ResurRenamingProc,
-			ResurRenamingAnnoProc), [Conj | Conjs],
-			!InCondRegionsProc)
-	;
-		Expr = disj([Disj | Disjs]),
-		list.foldl(collect_regions_created_in_condition(Graph, 
-			LRBeforeProc, LRAfterProc, ResurRenamingProc,
-			ResurRenamingAnnoProc), [Disj | Disjs],
-			!InCondRegionsProc)
-	;
-		Expr = switch(_, _, Cases),
-		list.foldl(
-			collect_regions_created_in_condition_case(Graph,
-			LRBeforeProc, LRAfterProc, ResurRenamingProc,
-			ResurRenamingAnnoProc),
-			Cases, !InCondRegionsProc)
-	;
-		Expr = negation(Goal),
-		collect_regions_created_in_condition(Graph, LRBeforeProc,
-			LRAfterProc, ResurRenamingProc,
-			ResurRenamingAnnoProc, Goal, !InCondRegionsProc)
-	;
-		Expr = scope(_, Goal),
-		collect_regions_created_in_condition(Graph, LRBeforeProc,
-			LRAfterProc, ResurRenamingProc,
-			ResurRenamingAnnoProc, Goal, !InCondRegionsProc)
-	;
-		Expr = if_then_else(_, Cond, Then, Else),
-		collect_regions_created_in_condition(Graph, LRBeforeProc,
-			LRAfterProc, ResurRenamingProc,
-			ResurRenamingAnnoProc, Cond, !InCondRegionsProc),
-		collect_regions_created_in_condition(Graph, LRBeforeProc,
-			LRAfterProc, ResurRenamingProc,
-			ResurRenamingAnnoProc, Then, !InCondRegionsProc),
-		collect_regions_created_in_condition(Graph, LRBeforeProc,
-			LRAfterProc, ResurRenamingProc,
-			ResurRenamingAnnoProc, Else, !InCondRegionsProc)
-	;
-		( Expr = unify(_, _, _, _, _) 
+        LRAfterProc, ResurRenamingProc, ResurRenamingAnnoProc, GoalInIte,
+        !InCondRegionsProc) :-
+    GoalInIte = hlds_goal(Expr, _),
+    (
+        Expr = conj(_, [Conj | Conjs]),
+        list.foldl(collect_regions_created_in_condition(Graph,
+            LRBeforeProc, LRAfterProc, ResurRenamingProc,
+            ResurRenamingAnnoProc), [Conj | Conjs],
+            !InCondRegionsProc)
+    ;
+        Expr = disj([Disj | Disjs]),
+        list.foldl(collect_regions_created_in_condition(Graph, 
+            LRBeforeProc, LRAfterProc, ResurRenamingProc,
+            ResurRenamingAnnoProc), [Disj | Disjs],
+            !InCondRegionsProc)
+    ;
+        Expr = switch(_, _, Cases),
+        list.foldl(
+            collect_regions_created_in_condition_case(Graph,
+            LRBeforeProc, LRAfterProc, ResurRenamingProc,
+            ResurRenamingAnnoProc),
+            Cases, !InCondRegionsProc)
+    ;
+        Expr = negation(Goal),
+        collect_regions_created_in_condition(Graph, LRBeforeProc,
+            LRAfterProc, ResurRenamingProc,
+            ResurRenamingAnnoProc, Goal, !InCondRegionsProc)
+    ;
+        Expr = scope(_, Goal),
+        collect_regions_created_in_condition(Graph, LRBeforeProc,
+            LRAfterProc, ResurRenamingProc,
+            ResurRenamingAnnoProc, Goal, !InCondRegionsProc)
+    ;
+        Expr = if_then_else(_, Cond, Then, Else),
+        collect_regions_created_in_condition(Graph, LRBeforeProc,
+            LRAfterProc, ResurRenamingProc,
+            ResurRenamingAnnoProc, Cond, !InCondRegionsProc),
+        collect_regions_created_in_condition(Graph, LRBeforeProc,
+            LRAfterProc, ResurRenamingProc,
+            ResurRenamingAnnoProc, Then, !InCondRegionsProc),
+        collect_regions_created_in_condition(Graph, LRBeforeProc,
+            LRAfterProc, ResurRenamingProc,
+            ResurRenamingAnnoProc, Else, !InCondRegionsProc)
+    ;
+        ( Expr = unify(_, _, _, _, _) 
         ; Expr = plain_call(_, _, _, _, _, _) 
         ; Expr = conj(_, [])
         ; Expr = disj([])
@@ -700,23 +692,23 @@
         ; Expr = generic_call(_, _, _, _)
         ; Expr = shorthand(_)
         ),
-		unexpected(this_file,
+        unexpected(this_file,
             "collect_regions_created_in_condition_compound_goal: "
-			++ "encountered atomic or unsupported goal")
-	).
+            ++ "encountered atomic or unsupported goal")
+    ).
 
 :- pred collect_regions_created_in_condition_case(rpt_graph::in,
-	pp_region_set_table::in, pp_region_set_table::in,
-	renaming_proc::in, renaming_annotation_proc::in, case::in,
-	goal_path_regions_table::in, goal_path_regions_table::out) is det.
+    pp_region_set_table::in, pp_region_set_table::in,
+    renaming_proc::in, renaming_annotation_proc::in, case::in,
+    goal_path_regions_table::in, goal_path_regions_table::out) is det.
 
 collect_regions_created_in_condition_case(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc,
-		Case, !InCondRegionsProc) :-
-	Case = case(_, Goal),
-	collect_regions_created_in_condition(Graph, LRBeforeProc, LRAfterProc,
-		ResurRenamingProc, ResurRenamingAnnoProc,
-		Goal, !InCondRegionsProc).
+        ResurRenamingProc, ResurRenamingAnnoProc,
+        Case, !InCondRegionsProc) :-
+    Case = case(_, Goal),
+    collect_regions_created_in_condition(Graph, LRBeforeProc, LRAfterProc,
+        ResurRenamingProc, ResurRenamingAnnoProc,
+        Goal, !InCondRegionsProc).
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -728,48 +720,48 @@
 %
 
 collect_ite_renamed_regions(InCondRegionsTable, NonLocalRegionsTable,
-		IteRenamedRegionsTable) :-
-	map.foldl(collect_ite_renamed_regions_proc(NonLocalRegionsTable), 
-		InCondRegionsTable, map.init, IteRenamedRegionsTable).
+        IteRenamedRegionsTable) :-
+    map.foldl(collect_ite_renamed_regions_proc(NonLocalRegionsTable), 
+        InCondRegionsTable, map.init, IteRenamedRegionsTable).
 
 :- pred collect_ite_renamed_regions_proc(proc_goal_path_regions_table::in,
-	pred_proc_id::in, goal_path_regions_table::in,
-	proc_goal_path_regions_table::in, proc_goal_path_regions_table::out)
-	is det.
+    pred_proc_id::in, goal_path_regions_table::in,
+    proc_goal_path_regions_table::in, proc_goal_path_regions_table::out)
+    is det.
 
 collect_ite_renamed_regions_proc(NonLocalRegionsTable, PPId,
-		InCondRegionsProc, !IteRenamedRegionTable) :-
-	( if	map.search(NonLocalRegionsTable, PPId, NonLocalRegionsProc)
-	  then
-			map.foldl(collect_ite_renamed_regions_ite(
-				NonLocalRegionsProc),
-				InCondRegionsProc,
-				map.init, IteRenamedRegionProc),
-			( if	map.count(IteRenamedRegionProc) = 0
-			  then	true
-			  else	svmap.set(PPId, IteRenamedRegionProc,
-						!IteRenamedRegionTable)
-			)
-	  else	true
-	).
+        InCondRegionsProc, !IteRenamedRegionTable) :-
+    ( if    map.search(NonLocalRegionsTable, PPId, NonLocalRegionsProc)
+      then
+            map.foldl(collect_ite_renamed_regions_ite(
+                NonLocalRegionsProc),
+                InCondRegionsProc,
+                map.init, IteRenamedRegionProc),
+            ( if    map.count(IteRenamedRegionProc) = 0
+              then  true
+              else  svmap.set(PPId, IteRenamedRegionProc,
+                        !IteRenamedRegionTable)
+            )
+      else  true
+    ).
 
 :- pred collect_ite_renamed_regions_ite(goal_path_regions_table::in,
-	goal_path::in, set(string)::in,
-	goal_path_regions_table::in, goal_path_regions_table::out) is det.
+    goal_path::in, set(string)::in,
+    goal_path_regions_table::in, goal_path_regions_table::out) is det.
 
 collect_ite_renamed_regions_ite(NonLocalRegionsProc, PathToCond,
-		InCondRegions, !IteRenamedRegionProc) :-
-	( if	map.search(NonLocalRegionsProc, PathToCond, NonLocalRegions)
-	  then
-			set.intersect(NonLocalRegions, InCondRegions,
-				RenamedRegions),
-			( if	set.empty(RenamedRegions)
-			  then	true
-			  else	svmap.set(PathToCond, RenamedRegions,
-						!IteRenamedRegionProc)
-			)
-	  else	true
-	).
+        InCondRegions, !IteRenamedRegionProc) :-
+    ( if    map.search(NonLocalRegionsProc, PathToCond, NonLocalRegions)
+      then
+            set.intersect(NonLocalRegions, InCondRegions,
+                RenamedRegions),
+            ( if    set.empty(RenamedRegions)
+              then  true
+              else  svmap.set(PathToCond, RenamedRegions,
+                        !IteRenamedRegionProc)
+            )
+      else  true
+    ).
 
 %-----------------------------------------------------------------------------%
 %
@@ -777,193 +769,191 @@
 %
 
 collect_ite_renaming(ModuleInfo, RptaInfoTable, IteRenamedRegionTable,
-		IteRenamingTable) :-
-	map.foldl(collect_ite_renaming_proc(ModuleInfo, RptaInfoTable),
-		IteRenamedRegionTable, map.init, IteRenamingTable).
+        IteRenamingTable) :-
+    map.foldl(collect_ite_renaming_proc(ModuleInfo, RptaInfoTable),
+        IteRenamedRegionTable, map.init, IteRenamingTable).
 
 :- pred collect_ite_renaming_proc(module_info::in, rpta_info_table::in,
-	pred_proc_id::in, goal_path_regions_table::in,
-	renaming_table::in, renaming_table::out) is det.
+    pred_proc_id::in, goal_path_regions_table::in,
+    renaming_table::in, renaming_table::out) is det.
 
 collect_ite_renaming_proc(ModuleInfo, RptaInfoTable,
-		PPId, IteRenamedRegionProc, !IteRenamingTable) :-
-	module_info_proc_info(ModuleInfo, PPId, ProcInfo0),
-	fill_goal_path_slots(ModuleInfo, ProcInfo0, ProcInfo),
-	proc_info_get_goal(ProcInfo, Goal),
-	map.lookup(RptaInfoTable, PPId, RptaInfo),
-	RptaInfo = rpta_info(Graph, _),
-	collect_ite_renaming_goal(IteRenamedRegionProc, Graph, Goal,
-		map.init, IteRenamingProc),
-	svmap.set(PPId, IteRenamingProc, !IteRenamingTable).
+        PPId, IteRenamedRegionProc, !IteRenamingTable) :-
+    module_info_proc_info(ModuleInfo, PPId, ProcInfo0),
+    fill_goal_path_slots(ModuleInfo, ProcInfo0, ProcInfo),
+    proc_info_get_goal(ProcInfo, Goal),
+    map.lookup(RptaInfoTable, PPId, RptaInfo),
+    RptaInfo = rpta_info(Graph, _),
+    collect_ite_renaming_goal(IteRenamedRegionProc, Graph, Goal,
+        map.init, IteRenamingProc),
+    svmap.set(PPId, IteRenamingProc, !IteRenamingTable).
 
 :- pred collect_ite_renaming_goal(goal_path_regions_table::in,
-	rpt_graph::in, hlds_goal::in, renaming_proc::in,
-	renaming_proc::out) is det.
+    rpt_graph::in, hlds_goal::in, renaming_proc::in,
+    renaming_proc::out) is det.
 
 collect_ite_renaming_goal(IteRenamedRegionProc, Graph, Goal,
-		!IteRenamingProc) :-
-	Goal = hlds_goal(Expr, _),
-	collect_ite_renaming_expr(Expr, IteRenamedRegionProc, Graph,
-		!IteRenamingProc).
+        !IteRenamingProc) :-
+    Goal = hlds_goal(Expr, _),
+    collect_ite_renaming_expr(Expr, IteRenamedRegionProc, Graph,
+        !IteRenamingProc).
 
 :- pred collect_ite_renaming_expr(hlds_goal_expr::in,
-	goal_path_regions_table::in, rpt_graph::in, renaming_proc::in,
-	renaming_proc::out) is det.
+    goal_path_regions_table::in, rpt_graph::in, renaming_proc::in,
+    renaming_proc::out) is det.
 
 collect_ite_renaming_expr(conj(_, Conjs), IteRenamedRegionProc,
-		Graph, !IteRenamingProc) :- 
+        Graph, !IteRenamingProc) :- 
     list.foldl(collect_ite_renaming_goal(IteRenamedRegionProc, Graph),
-		Conjs, !IteRenamingProc). 
+        Conjs, !IteRenamingProc). 
 
 collect_ite_renaming_expr(plain_call(_, _, _, _, _, _), _, _,
-		!IteRenamingProc).
+        !IteRenamingProc).
 collect_ite_renaming_expr(generic_call(_, _, _, _), _, _, 
-		!IteRenamingProc).
+        !IteRenamingProc).
 collect_ite_renaming_expr(call_foreign_proc(_, _, _, _, _, _, _),
-		_, _, !IteRenamingProc).
+        _, _, !IteRenamingProc).
 
 collect_ite_renaming_expr(switch(_, _, Cases), IteRenamedRegionProc,
-		Graph, !IteRenamingProc) :- 
+        Graph, !IteRenamingProc) :- 
     list.foldl(
-		collect_ite_renaming_case(IteRenamedRegionProc, Graph),
-		Cases, !IteRenamingProc).
+        collect_ite_renaming_case(IteRenamedRegionProc, Graph),
+        Cases, !IteRenamingProc).
 collect_ite_renaming_expr(disj(Disjs), IteRenamedRegionProc, Graph,
-		!IteRenamingProc) :-
+        !IteRenamingProc) :-
     list.foldl(
-		collect_ite_renaming_goal(IteRenamedRegionProc, Graph),
-		Disjs, !IteRenamingProc). 
+        collect_ite_renaming_goal(IteRenamedRegionProc, Graph),
+        Disjs, !IteRenamingProc). 
 collect_ite_renaming_expr(negation(Goal), IteRenamedRegionProc, Graph,
-		!IteRenamingProc) :- 
+        !IteRenamingProc) :- 
     collect_ite_renaming_goal(IteRenamedRegionProc, Graph, Goal,
-		!IteRenamingProc). 
+        !IteRenamingProc). 
 collect_ite_renaming_expr(unify(_, _, _, _, _), _, _, !IteRenamingProc).
 
 collect_ite_renaming_expr(scope(_, Goal), IteRenamedRegionProc,
-		Graph, !IteRenamingProc) :- 
-	collect_ite_renaming_goal(IteRenamedRegionProc, Graph, Goal,
-		!IteRenamingProc).
+        Graph, !IteRenamingProc) :- 
+    collect_ite_renaming_goal(IteRenamedRegionProc, Graph, Goal,
+        !IteRenamingProc).
 
 collect_ite_renaming_expr(shorthand(_), _, _, !IteRenamingProc) :- 
-    unexpected(this_file,
-		"collect_ite_renaming_expr: shorthand not handled").
+    unexpected(this_file, "collect_ite_renaming_expr: shorthand not handled").
 
 collect_ite_renaming_expr(Expr, IteRenamedRegionProc, Graph,
-		!IteRenamingProc) :- 
-	Expr = if_then_else(_, Cond, Then, Else),
+        !IteRenamingProc) :- 
+    Expr = if_then_else(_, Cond, Then, Else),
 
-	% Renaming for if-then-else only happens in condition goals.
-	collect_ite_renaming_in_condition(IteRenamedRegionProc, Graph, Cond,
-		!IteRenamingProc),
+    % Renaming for if-then-else only happens in condition goals.
+    collect_ite_renaming_in_condition(IteRenamedRegionProc, Graph, Cond,
+        !IteRenamingProc),
 
     collect_ite_renaming_goal(IteRenamedRegionProc, Graph, Then,
-		!IteRenamingProc),
+        !IteRenamingProc),
     collect_ite_renaming_goal(IteRenamedRegionProc, Graph, Else,
-		!IteRenamingProc).
+        !IteRenamingProc).
 
 :- pred collect_ite_renaming_case(goal_path_regions_table::in, 
-	rpt_graph::in, case::in, renaming_proc::in,
-	renaming_proc::out) is det.
+    rpt_graph::in, case::in, renaming_proc::in,
+    renaming_proc::out) is det.
 
 collect_ite_renaming_case(IteRenamedRegionProc, Graph, Case,
-		!IteRenamingProc) :-
-	Case = case(_, Goal),
-	collect_ite_renaming_goal(IteRenamedRegionProc, Graph, Goal,
-		!IteRenamingProc).
+        !IteRenamingProc) :-
+    Case = case(_, Goal),
+    collect_ite_renaming_goal(IteRenamedRegionProc, Graph, Goal,
+        !IteRenamingProc).
 
-	% Introduce renaming for each program point in a condition goal.
-	%
+    % Introduce renaming for each program point in a condition goal.
+    %
 :- pred collect_ite_renaming_in_condition(
-	goal_path_regions_table::in, rpt_graph::in, hlds_goal::in,
-	renaming_proc::in, renaming_proc::out) is det.
+    goal_path_regions_table::in, rpt_graph::in, hlds_goal::in,
+    renaming_proc::in, renaming_proc::out) is det.
 
 collect_ite_renaming_in_condition(IteRenamedRegionProc, Graph, Cond,
-		!IteRenamingProc) :-
-	Cond = hlds_goal(Expr, Info),
-	( if	goal_is_atomic(Expr)
-	  then
-			ProgPoint = program_point_init(Info),
-			% It is enough to look for the regions to be renamed 
-			% at the closest condition because if a region is 
-			% to be renamed for a compounding if-then-else of the
-			% closest if-then-else then it also needs to be renamed
-			% for the closest if-then-else. 
-			ProgPoint = pp(_, GoalPath),
-			get_closest_condition_in_goal_path(GoalPath,
-				PathToClosestCond, 0, HowMany),
-			( if	map.search(IteRenamedRegionProc,
-						PathToClosestCond,
-						RenamedRegions)
-			  then
-					set.fold(record_ite_renaming(ProgPoint,
-						HowMany, Graph),
-						RenamedRegions,
-						!IteRenamingProc)
-			  else
-					% No region needs to be renamed due to
-					% if-then-else covering this program
-					% point.
-					true
-			)
-	  else
-			collect_ite_renaming_in_condition_compound_goal(
-				IteRenamedRegionProc, Graph, Cond,
-				!IteRenamingProc)
-	).
+        !IteRenamingProc) :-
+    Cond = hlds_goal(Expr, Info),
+    ( if    goal_is_atomic(Expr)
+      then
+            ProgPoint = program_point_init(Info),
+            % It is enough to look for the regions to be renamed 
+            % at the closest condition because if a region is 
+            % to be renamed for a compounding if-then-else of the
+            % closest if-then-else then it also needs to be renamed
+            % for the closest if-then-else. 
+            ProgPoint = pp(_, GoalPath),
+            get_closest_condition_in_goal_path(GoalPath,
+                PathToClosestCond, 0, HowMany),
+            ( if    map.search(IteRenamedRegionProc,
+                        PathToClosestCond,
+                        RenamedRegions)
+              then
+                    set.fold(record_ite_renaming(ProgPoint,
+                        HowMany, Graph),
+                        RenamedRegions,
+                        !IteRenamingProc)
+              else
+                    % No region needs to be renamed due to
+                    % if-then-else covering this program
+                    % point.
+                    true
+            )
+      else  collect_ite_renaming_in_condition_compound_goal(
+                IteRenamedRegionProc, Graph, Cond,
+                !IteRenamingProc)
+    ).
 
-	% A renaming is of the form: R --> R_ite_HowMany.
-	%
+    % A renaming is of the form: R --> R_ite_HowMany.
+    %
 :- pred record_ite_renaming(program_point::in, int::in, rpt_graph::in,
-	string::in, renaming_proc::in, renaming_proc::out) is det.
+    string::in, renaming_proc::in, renaming_proc::out) is det.
 
 record_ite_renaming(ProgPoint, HowMany, _Graph, RegName, !IteRenamingProc) :-
-	NewName = RegName ++ "_ite_" ++ string.int_to_string(HowMany),
-	( if	map.search(!.IteRenamingProc, ProgPoint, IteRenaming0)
-	  then 	svmap.set(RegName, NewName, IteRenaming0, IteRenaming)
-	  else	svmap.set(RegName, NewName, map.init, IteRenaming)
-	),
-	svmap.set(ProgPoint, IteRenaming, !IteRenamingProc).
+    NewName = RegName ++ "_ite_" ++ string.int_to_string(HowMany),
+    ( if    map.search(!.IteRenamingProc, ProgPoint, IteRenaming0)
+      then  svmap.set(RegName, NewName, IteRenaming0, IteRenaming)
+      else  svmap.set(RegName, NewName, map.init, IteRenaming)
+    ),
+    svmap.set(ProgPoint, IteRenaming, !IteRenamingProc).
 
 :- pred collect_ite_renaming_in_condition_compound_goal(
-	goal_path_regions_table::in, rpt_graph::in, hlds_goal::in,
-	renaming_proc::in, renaming_proc::out) is det.
+    goal_path_regions_table::in, rpt_graph::in, hlds_goal::in,
+    renaming_proc::in, renaming_proc::out) is det.
 
 collect_ite_renaming_in_condition_compound_goal(IteRenamedRegionProc,
-		Graph, GoalInCond, !IteRenamingProc) :-
-	GoalInCond = hlds_goal(Expr, _),
-	(
-		Expr = conj(_, [Conj | Conjs]),
-		list.foldl(collect_ite_renaming_in_condition(
-			IteRenamedRegionProc, Graph), [Conj | Conjs],
-			!IteRenamingProc)
-	;
-		Expr = disj([Disj | Disjs]),
-		list.foldl(collect_ite_renaming_in_condition(
-			IteRenamedRegionProc, Graph), [Disj | Disjs],
-			!IteRenamingProc)
-	;
-		Expr = switch(_, _, Cases),
-		list.foldl(
-			collect_ite_renaming_in_condition_case(
-				IteRenamedRegionProc, Graph), Cases,
-				!IteRenamingProc)
-	;
-		Expr = negation(Goal),
-		collect_ite_renaming_in_condition(IteRenamedRegionProc,
-			Graph, Goal, !IteRenamingProc)
-	;
-		Expr = scope(_, Goal),
-		collect_ite_renaming_in_condition(IteRenamedRegionProc,
-			Graph, Goal, !IteRenamingProc)
-	;
-		Expr = if_then_else(_, Cond, Then, Else),
-		collect_ite_renaming_in_condition(IteRenamedRegionProc,
-			Graph, Cond, !IteRenamingProc),
-		collect_ite_renaming_in_condition(IteRenamedRegionProc,
-			Graph, Then, !IteRenamingProc),
-		collect_ite_renaming_in_condition(IteRenamedRegionProc,
-			Graph, Else, !IteRenamingProc)
-	;
-		( Expr = unify(_, _, _, _, _) 
+        Graph, GoalInCond, !IteRenamingProc) :-
+    GoalInCond = hlds_goal(Expr, _),
+    (
+        Expr = conj(_, [Conj | Conjs]),
+        list.foldl(collect_ite_renaming_in_condition(
+            IteRenamedRegionProc, Graph), [Conj | Conjs],
+            !IteRenamingProc)
+    ;
+        Expr = disj([Disj | Disjs]),
+        list.foldl(collect_ite_renaming_in_condition(
+            IteRenamedRegionProc, Graph), [Disj | Disjs],
+            !IteRenamingProc)
+    ;
+        Expr = switch(_, _, Cases),
+        list.foldl(
+            collect_ite_renaming_in_condition_case(
+                IteRenamedRegionProc, Graph), Cases,
+                !IteRenamingProc)
+    ;
+        Expr = negation(Goal),
+        collect_ite_renaming_in_condition(IteRenamedRegionProc,
+            Graph, Goal, !IteRenamingProc)
+    ;
+        Expr = scope(_, Goal),
+        collect_ite_renaming_in_condition(IteRenamedRegionProc,
+            Graph, Goal, !IteRenamingProc)
+    ;
+        Expr = if_then_else(_, Cond, Then, Else),
+        collect_ite_renaming_in_condition(IteRenamedRegionProc,
+            Graph, Cond, !IteRenamingProc),
+        collect_ite_renaming_in_condition(IteRenamedRegionProc,
+            Graph, Then, !IteRenamingProc),
+        collect_ite_renaming_in_condition(IteRenamedRegionProc,
+            Graph, Else, !IteRenamingProc)
+    ;
+        ( Expr = unify(_, _, _, _, _) 
         ; Expr = plain_call(_, _, _, _, _, _) 
         ; Expr = conj(_, [])
         ; Expr = disj([])
@@ -971,33 +961,33 @@
         ; Expr = generic_call(_, _, _, _)
         ; Expr = shorthand(_)
         ),
-		unexpected(this_file,
+        unexpected(this_file,
             "collect_ite_renaming_in_condition_compound_goal: "
-			++ "encountered atomic or unsupported goal")
-	).
+            ++ "encountered atomic or unsupported goal")
+    ).
 
 :- pred collect_ite_renaming_in_condition_case(
-	goal_path_regions_table::in, rpt_graph::in, case::in,
-	renaming_proc::in, renaming_proc::out) is det.
+    goal_path_regions_table::in, rpt_graph::in, case::in,
+    renaming_proc::in, renaming_proc::out) is det.
 
 collect_ite_renaming_in_condition_case(IteRenamedRegionProc, Graph, Case,
-		!IteRenamingProc) :-
-	Case = case(_, Goal),
-	collect_ite_renaming_in_condition(IteRenamedRegionProc, Graph, Goal,
-		!IteRenamingProc).
-
-	% This predicate receives a goal path (to some goal) and returns
-	% the subpath to the closest condition containing the goal. It also 
-	% returns the number of conditions that contain the goal.
-	% If the goal is in no condition, the output path is empty.
-	% e.g., ( if
-	%			( if
-	%				goal
-	%				...
-	% then HowMany is 2.
-	%
+        !IteRenamingProc) :-
+    Case = case(_, Goal),
+    collect_ite_renaming_in_condition(IteRenamedRegionProc, Graph, Goal,
+        !IteRenamingProc).
+
+    % This predicate receives a goal path (to some goal) and returns
+    % the subpath to the closest condition containing the goal. It also 
+    % returns the number of conditions that contain the goal.
+    % If the goal is in no condition, the output path is empty.
+    % e.g., ( if
+    %           ( if
+    %               goal
+    %               ...
+    % then HowMany is 2.
+    %
 :- pred get_closest_condition_in_goal_path(goal_path::in,
-	goal_path::out, int::in, int::out) is det.
+    goal_path::out, int::in, int::out) is det.
 get_closest_condition_in_goal_path([], [], !HowMany).
 get_closest_condition_in_goal_path([Step | Steps], PathToCond, !HowMany) :-
     ( if    Step = step_ite_cond
@@ -1005,8 +995,7 @@
             PathToCond = [Step | Steps],
             get_closest_condition_in_goal_path(Steps, _, !.HowMany, HowMany),
             !:HowMany = HowMany + 1
-      else
-            get_closest_condition_in_goal_path(Steps, PathToCond, !HowMany)
+      else  get_closest_condition_in_goal_path(Steps, PathToCond, !HowMany)
     ).
 
 %-----------------------------------------------------------------------------%
@@ -1015,99 +1004,98 @@
 %
 
 collect_ite_annotation(IteRenamedRegionTable, ExecPathTable,
-		RptaInfoTable, IteRenamingTable, IteAnnotationTable) :-
-	map.foldl(collect_ite_annotation_proc(ExecPathTable, RptaInfoTable,
-					IteRenamingTable),
-		IteRenamedRegionTable, map.init, IteAnnotationTable).
+        RptaInfoTable, IteRenamingTable, IteAnnotationTable) :-
+    map.foldl(collect_ite_annotation_proc(ExecPathTable, RptaInfoTable,
+                    IteRenamingTable),
+        IteRenamedRegionTable, map.init, IteAnnotationTable).
 
 :- pred collect_ite_annotation_proc(execution_path_table::in,
-	rpta_info_table::in, renaming_table::in, pred_proc_id::in,
-	goal_path_regions_table::in,
-	renaming_annotation_table::in, renaming_annotation_table::out) is det.
+    rpta_info_table::in, renaming_table::in, pred_proc_id::in,
+    goal_path_regions_table::in,
+    renaming_annotation_table::in, renaming_annotation_table::out) is det.
 
 collect_ite_annotation_proc(ExecPathTable, RptaInfoTable, IteRenamingTable,
-		PPId, IteRenamedRegionProc, !IteAnnotationTable) :-
-	map.lookup(ExecPathTable, PPId, ExecPaths),
-	map.lookup(RptaInfoTable, PPId, RptaInfo),
-	map.lookup(IteRenamingTable, PPId, IteRenamingProc),
-	RptaInfo = rpta_info(Graph, _),
-	map.foldl(collect_ite_annotation_region_names(ExecPaths, Graph,
-		IteRenamingProc),
-		IteRenamedRegionProc, map.init, IteAnnotationProc),
-	svmap.set(PPId, IteAnnotationProc, !IteAnnotationTable).
+        PPId, IteRenamedRegionProc, !IteAnnotationTable) :-
+    map.lookup(ExecPathTable, PPId, ExecPaths),
+    map.lookup(RptaInfoTable, PPId, RptaInfo),
+    map.lookup(IteRenamingTable, PPId, IteRenamingProc),
+    RptaInfo = rpta_info(Graph, _),
+    map.foldl(collect_ite_annotation_region_names(ExecPaths, Graph,
+        IteRenamingProc),
+        IteRenamedRegionProc, map.init, IteAnnotationProc),
+    svmap.set(PPId, IteAnnotationProc, !IteAnnotationTable).
 
 :- pred collect_ite_annotation_region_names(list(execution_path)::in,
-	rpt_graph::in, renaming_proc::in, goal_path::in, set(string)::in,
-	renaming_annotation_proc::in, renaming_annotation_proc::out) is det.
+    rpt_graph::in, renaming_proc::in, goal_path::in, set(string)::in,
+    renaming_annotation_proc::in, renaming_annotation_proc::out) is det.
 
 collect_ite_annotation_region_names(ExecPaths, Graph, IteRenamingProc,
-		PathToCond, RenamedRegions, !IteAnnotationProc) :-
-	(
-		PathToCond = [],
-		unexpected(this_file,
-			"collect_ite_annotation_region_set: " ++
-			"empty path to condition.")
-	;
-		PathToCond = [_ | Steps],
-		PathToThen = [step_ite_then | Steps],
-		get_closest_condition_in_goal_path(PathToCond, _, 0, HowMany),
-		list.foldl(collect_ite_annotation_exec_path(Graph,
-			IteRenamingProc, PathToThen,
-			RenamedRegions, HowMany), ExecPaths,
-			!IteAnnotationProc)
-	).
+        PathToCond, RenamedRegions, !IteAnnotationProc) :-
+    (
+        PathToCond = [],
+        unexpected(this_file,
+            "collect_ite_annotation_region_set: " ++
+            "empty path to condition.")
+    ;
+        PathToCond = [_ | Steps],
+        PathToThen = [step_ite_then | Steps],
+        get_closest_condition_in_goal_path(PathToCond, _, 0, HowMany),
+        list.foldl(collect_ite_annotation_exec_path(Graph,
+            IteRenamingProc, PathToThen,
+            RenamedRegions, HowMany), ExecPaths,
+            !IteAnnotationProc)
+    ).
 
 :- pred collect_ite_annotation_exec_path(rpt_graph::in,
-	renaming_proc::in, goal_path::in,
-	set(string)::in, int::in, execution_path::in,
-	renaming_annotation_proc::in, renaming_annotation_proc::out) is det.
+    renaming_proc::in, goal_path::in,
+    set(string)::in, int::in, execution_path::in,
+    renaming_annotation_proc::in, renaming_annotation_proc::out) is det.
 
 collect_ite_annotation_exec_path(_, _, _, _, _, [], !IteAnnotationProc).
 collect_ite_annotation_exec_path(Graph, IteRenamingProc, PathToThen,
-		RenamedRegions, HowMany,
-		[ProgPoint - _ | ProgPoint_Goals], !IteAnnotationProc) :-
-	ProgPoint = pp(_, GoalPath),
-	( if	list.append(_, PathToThen, GoalPath)
-	  then
-			% This is the first goal in the corresponding then
-			% branch, we need to introduce reverse renaming at
-			% this point.
-			set.fold(introduce_reverse_renaming(Graph, ProgPoint,
-				IteRenamingProc, HowMany),
-				RenamedRegions, !IteAnnotationProc)
-	  else
-			collect_ite_annotation_exec_path(Graph, IteRenamingProc,
-				PathToThen, RenamedRegions, HowMany,
-				ProgPoint_Goals, !IteAnnotationProc)
-	).
-
-	% The reverse renaming annotation is in the form: R = R_ite_HowMany.
-	% The annotation is attached to the program point but actually means
-	% to be added before the program point.
-	% If there exists a renaming at the program point related to R, e.g.,
-	% R --> R_1, then the annotation is R_1 = R_ite_HowMany.
-	%
-:- pred introduce_reverse_renaming(rpt_graph::in, program_point::in,
-	renaming_proc::in, int::in, string::in,
-	renaming_annotation_proc::in, renaming_annotation_proc::out) is det.
-
-introduce_reverse_renaming(_Graph, ProgPoint, IteRenamingProc,
-		HowMany, RegName, !IteAnnotationProc) :-
-	RightHand =
-		" = " ++ RegName ++ "_ite_" ++ string.int_to_string(HowMany),
-	( if	map.search(IteRenamingProc, ProgPoint, Renaming)
-	  then
-			( if	map.search(Renaming, RegName, RenameTo)
-			  then
-					Anno = RenameTo ++ RightHand 
-			  else
-					Anno = RegName ++ RightHand 
-			)
-	  else
-			% No renaming exists at this program point.
-			Anno = RegName ++ RightHand
-	),
-	record_annotation(ProgPoint, Anno, !IteAnnotationProc).
+        RenamedRegions, HowMany,
+        [ProgPoint - _ | ProgPoint_Goals], !IteAnnotationProc) :-
+    ProgPoint = pp(_, GoalPath),
+    ( if    list.append(_, PathToThen, GoalPath)
+      then
+            % This is the first goal in the corresponding then
+            % branch, we need to introduce reverse renaming at
+            % this point.
+            set.fold(introduce_reverse_renaming(ProgPoint,
+                IteRenamingProc, HowMany),
+                RenamedRegions, !IteAnnotationProc)
+      else  collect_ite_annotation_exec_path(Graph, IteRenamingProc,
+                PathToThen, RenamedRegions, HowMany,
+                ProgPoint_Goals, !IteAnnotationProc)
+    ).
+
+    % The reverse renaming annotation is in the form: R = R_ite_HowMany.
+    % The annotation is attached to the program point but actually means
+    % to be added before the program point.
+    % If there exists a renaming at the program point related to R, e.g.,
+    % R --> R_1, then the annotation is R_1 = R_ite_HowMany.
+    %
+:- pred introduce_reverse_renaming(program_point::in,
+    renaming_proc::in, int::in, string::in,
+    renaming_annotation_proc::in, renaming_annotation_proc::out) is det.
+
+introduce_reverse_renaming(ProgPoint, IteRenamingProc, HowMany, RegName,
+        !IteAnnotationProc) :-
+    CurrentName = RegName ++ "_ite_" ++ string.int_to_string(HowMany),
+    ( if    map.search(IteRenamingProc, ProgPoint, Renaming)
+      then
+            ( if    map.search(Renaming, RegName, RenameTo)
+              then  make_renaming_instruction(CurrentName, RenameTo,
+                        Annotation)
+              else  make_renaming_instruction(CurrentName, RegName,
+                        Annotation)
+            )
+      else
+            % No renaming exists at this program point.
+            make_renaming_instruction(CurrentName, RegName,
+                Annotation)
+    ),
+    record_annotation(ProgPoint, Annotation, !IteAnnotationProc).
 
 %-----------------------------------------------------------------------------%
 
Index: rbmm.region_resurrection_renaming.m
===================================================================
RCS file:
/home/mercury/mercury1/repository/mercury/compiler/rbmm.region_resurrection_renaming.m,v
retrieving revision 1.3
diff -u -u -r1.3 rbmm.region_resurrection_renaming.m
--- rbmm.region_resurrection_renaming.m	6 Jul 2007 02:35:23 -0000	1.3
+++ rbmm.region_resurrection_renaming.m	19 Jul 2007 05:56:03 -0000
@@ -26,6 +26,7 @@
 :- import_module hlds.hlds_pred.
 :- import_module transform_hlds.smm_common.
 :- import_module transform_hlds.rbmm.points_to_info.
+:- import_module transform_hlds.rbmm.region_instruction.
 :- import_module transform_hlds.rbmm.region_liveness_info.
 
 :- import_module list.
@@ -35,7 +36,7 @@
 %-----------------------------------------------------------------------------%
 
 :- type renaming_table ==
-	map(pred_proc_id, renaming_proc).
+    map(pred_proc_id, renaming_proc).
 
 :- type renaming_proc ==
     map(program_point, renaming).
@@ -46,7 +47,7 @@
     map(pred_proc_id, renaming_annotation_proc).
 
 :- type renaming_annotation_proc ==
-    map(program_point, list(string)).
+    map(program_point, list(region_instruction)).
 
 :- type proc_resurrection_path_table ==
     map(pred_proc_id, exec_path_region_set_table).
@@ -117,9 +118,14 @@
 
     % Record the annotation for a procedure.
     % 
-:- pred record_annotation(program_point::in, string::in,
+:- pred record_annotation(program_point::in, region_instruction::in,
     renaming_annotation_proc::in, renaming_annotation_proc::out) is det.
 
+    % Make a region renaming instruction.
+    %
+:- pred make_renaming_instruction(string::in, string::in,
+    region_instruction::out) is det.
+
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
@@ -646,15 +652,16 @@
     % XXX Annotations are only added for resurrected regions that have been
     % renamed in this execution path (i.e., the execution path contains
     % PrevProgPoint and ProgPoint).
-    % It seems that we have to add annotations (reverse renaming) for
-    % ones that have not been renamed too. The only difference is that
+    % It seems that we have to add annotations (reverse renaming) for ones that
+    % have not been renamed as implemented below too. The only difference is
+    % that
     % the reverse renaming is between the new name and the original name.
     ( if    map.search(PrevRenaming, RegionName, CurrentName)
       then
-            Annotation = NewName ++ " = " ++ CurrentName,
+            make_renaming_instruction(CurrentName, NewName, Annotation),
             record_annotation(PrevProgPoint, Annotation, !AnnotationProc)
       else
-            Annotation = NewName ++ " = " ++ RegionName,
+            make_renaming_instruction(RegionName, NewName, Annotation),
             record_annotation(PrevProgPoint, Annotation, !AnnotationProc)
     ).
 
@@ -670,7 +677,7 @@
     % renamed in this execution path.
     ( if    map.search(Renaming, RegionName, CurrentName)
       then
-            Annotation = RegionName ++ " = " ++ CurrentName,
+            make_renaming_instruction(CurrentName, RegionName, Annotation),
             record_annotation(ProgPoint, Annotation, !AnnotationProc)
       else  true
     ).
@@ -688,6 +695,8 @@
     ),
     svmap.set(ProgPoint, Annotations, !AnnotationProc).
 
+make_renaming_instruction(OldRegionName, NewRegionName, RenameInstruction) :-
+    RenameInstruction = rename_region(OldRegionName, NewRegionName).
 %-----------------------------------------------------------------------------%
 
 :- func this_file = string.
Index: prog_type.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_type.m,v
retrieving revision 1.35
diff -u -u -r1.35 prog_type.m
--- prog_type.m	2 Jul 2007 05:30:30 -0000	1.35
+++ prog_type.m	19 Jul 2007 05:56:03 -0000
@@ -298,6 +298,7 @@
 :- func sample_typeclass_info_type = mer_type.
 :- func comparison_result_type = mer_type.
 :- func io_state_type = mer_type.
+:- func region_type = mer_type.
 
     % Construct the types of type_infos and type_ctor_infos.
     %
@@ -905,6 +906,10 @@
     Module = mercury_std_lib_module_name(unqualified("io")),
     Name = qualified(Module, "state").
 
+region_type = defined_type(Name, [], kind_star) :-
+    Module = mercury_region_builtin_module,
+    Name = qualified(Module, "region").
+
 %-----------------------------------------------------------------------------%
 
     % Given a constant and an arity, return a type_ctor.
--------------------------------------------------------------------------
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