[m-rev.] For post-commit review: Coverage profiling changes.

Paul Bone pbone at csse.unimelb.edu.au
Sat Sep 20 21:34:54 AEST 2008


For post-commit review by Zoltan.

Estimated hours taken: 0.5
Branches: main

Changes to coverage profiling system.  Remove the 3 'solution count' style
coverage point type and replace them with a single 'coverage after goal'
coverage point type.  Insert a coverage point after a goal even if the goal is
deterministic, therefor the separate coverage points used for goals of
different determinisms no-longer make sense.

mdbcomp/program_representation.m:
    Modify the coverage point types, and their foreign enumeration.

runtime/mercury_deep_profiling.h:
    Modify C enumeration of coverage point types.

compiler/options.m:
compiler/handle_options.m:
    Update coverage profiling options to match available coverage point types.

compiler/deep_profiling.m:
    Conform to changes in mdbcomp/program_representation.m and
    compiler/options.m.
    Insert coverage points after goals regardless of their determinism.

deep_profiler/create_report.m:
    Conform to changes in mdbcomp/program_representation.m

Index: compiler/deep_profiling.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.85
diff -u -p -b -r1.85 deep_profiling.m
--- compiler/deep_profiling.m	20 Sep 2008 09:22:41 -0000	1.85
+++ compiler/deep_profiling.m	20 Sep 2008 10:44:08 -0000
@@ -1946,9 +1946,7 @@ extract_deep_rec_info(MaybeDeepProfInfo,
                 % These fields correspond to coverage profiling options that
                 % may be specified on the command line.  Except cpu_use_2pass.
 
-                cpo_may_fail            :: bool,
-                cpo_multi               :: bool,
-                cpo_any                 :: bool,
+                cpo_coverage_after_goal :: bool,
                 cpo_branch_ite          :: bool,
                 cpo_branch_switch       :: bool,
                 cpo_branch_disj         :: bool,
@@ -1971,12 +1969,8 @@ coverage_profiling_options(ModuleInfo, C
     module_info_get_globals(ModuleInfo, Globals),
 
     % Coverage point types.
-    globals.lookup_bool_option(Globals, profile_deep_coverage_may_fail,
-        MayFail),
-    globals.lookup_bool_option(Globals, profile_deep_coverage_multi,
-        Multi),
-    globals.lookup_bool_option(Globals, profile_deep_coverage_any,
-        Any),
+    globals.lookup_bool_option(Globals, profile_deep_coverage_after_goal,
+        CoverageAfterGoal),
     globals.lookup_bool_option(Globals, profile_deep_coverage_branch_ite,
         BranchIf),
     globals.lookup_bool_option(Globals, profile_deep_coverage_branch_switch,
@@ -1991,7 +1985,7 @@ coverage_profiling_options(ModuleInfo, C
         UseTrivial),
     bool.or(UsePortCounts, UseTrivial, Use2Pass),
 
-    CoveragePointOptions = coverage_profiling_options(MayFail, Multi, Any,
+    CoveragePointOptions = coverage_profiling_options(CoverageAfterGoal,
         BranchIf, BranchSwitch, BranchDisj, UsePortCounts, UseTrivial,
         Use2Pass).
 
@@ -2027,8 +2021,7 @@ coverage_prof_transform_goal(ModuleInfo,
     % information from the goal_info structure.
     %
     % Step 1: Make a decision whether to insert a coverage point after this
-    % goal or not. This applies to may_fail multi and any coverage point
-    % types only. Other coverage point types are handled seperately.
+    % goal or not.
     %
     % Step 2: Determine if coverage information is known for goals that
     % execute before this goal completes. This includes goals before this
@@ -2110,55 +2103,12 @@ coverage_prof_second_pass_goal(Goal0, Go
     ->
         MaybeCPType = no
     ;
+        CoverageAfterGoals = CPOptions ^ cpo_coverage_after_goal,
         (
-            ( Detism = detism_semi
-            ; Detism = detism_cc_non
-            ),
-            CoverMayFail = CPOptions ^ cpo_may_fail,
-            (
-                CoverMayFail = yes,
-                MaybeCPType = yes(cp_type_solns_may_fail)
-            ;
-                CoverMayFail = no,
-                MaybeCPType = no
-            )
-        ;
-            Detism = detism_multi,
-            CoverMulti = CPOptions ^ cpo_multi,
-            (
-                CoverMulti = yes,
-                MaybeCPType = yes(cp_type_solns_multi)
-            ;
-                CoverMulti = no,
-                MaybeCPType = no
-            )
+            CoverageAfterGoals  = yes,
+            MaybeCPType = yes(cp_type_coverage_after)
         ;
-            Detism = detism_non,
-            CoverAny = CPOptions ^ cpo_any,
-            (
-                CoverAny = yes,
-                MaybeCPType = yes(cp_type_solns_any)
-            ;
-                CoverAny = no,
-                MaybeCPType = no
-            )
-        ;
-            ( Detism = detism_erroneous
-            ; Detism = detism_failure
-            ),
-            % Execution cannot reach the point after this goal, so we do not
-            % need a coverage point.
-            MaybeCPType = no
-        ;
-            ( Detism = detism_det
-            ; Detism = detism_cc_multi
-            ),
-            % Coverage isn't known here, however we do not insert a coverage
-            % point to count the solutions of the goal.  The coverage at this
-            % point may not be valuable, for example, the goal may be trivial.
-            % Or the goal may be a conjunction, in which case insert a coverage
-            % point after the last conjunct rather than after the whole
-            % conjunction.
+            CoverageAfterGoals = no,
             MaybeCPType = no
         )
     ),
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.324
diff -u -p -b -r1.324 handle_options.m
--- compiler/handle_options.m	5 Sep 2008 13:19:34 -0000	1.324
+++ compiler/handle_options.m	20 Sep 2008 10:40:34 -0000
@@ -1166,11 +1166,8 @@ postprocess_options_2(OptionTable0, Targ
         (
             ProfForImplicitParallelism = yes,
             globals.set_option(coverage_profiling, bool(yes), !Globals),
-            globals.set_option(profile_deep_coverage_may_fail, bool(yes),
+            globals.set_option(profile_deep_coverage_after_goal, bool(yes),
                 !Globals), 
-            globals.set_option(profile_deep_coverage_multi, bool(yes),
-                !Globals), 
-            globals.set_option(profile_deep_coverage_any, bool(yes), !Globals), 
             globals.set_option(profile_deep_coverage_branch_ite, bool(yes),
                 !Globals), 
             globals.set_option(profile_deep_coverage_branch_switch, bool(yes),
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.629
diff -u -p -b -r1.629 options.m
--- compiler/options.m	9 Sep 2008 01:37:30 -0000	1.629
+++ compiler/options.m	20 Sep 2008 10:40:08 -0000
@@ -298,9 +298,7 @@
     ;       coverage_profiling
    
             % What types of coverage points to instrument the code with.
-    ;       profile_deep_coverage_may_fail
-    ;       profile_deep_coverage_multi
-    ;       profile_deep_coverage_any
+    ;       profile_deep_coverage_after_goal
     ;       profile_deep_coverage_branch_ite
     ;       profile_deep_coverage_branch_switch
     ;       profile_deep_coverage_branch_disj
@@ -1165,9 +1163,7 @@ option_defaults_2(compilation_model_opti
     profile_deep                        -   bool(no),
     use_activation_counts               -   bool(no),
     coverage_profiling                  -   bool(no),
-    profile_deep_coverage_may_fail      -   bool(yes),
-    profile_deep_coverage_multi         -   bool(yes),
-    profile_deep_coverage_any           -   bool(yes),
+    profile_deep_coverage_after_goal    -   bool(yes),
     profile_deep_coverage_branch_ite    -   bool(yes),
     profile_deep_coverage_branch_switch -   bool(yes),
     profile_deep_coverage_branch_disj   -   bool(yes),
@@ -1996,12 +1992,8 @@ long_option("profile-deep",         prof
 long_option("use-activation-counts",    use_activation_counts).
 long_option("coverage-profiling", 
                     coverage_profiling).
-long_option("profile-deep-coverage-may-fail",
-                    profile_deep_coverage_may_fail).
-long_option("profile-deep-coverage-multi", 
-                    profile_deep_coverage_multi).
-long_option("profile-deep-coverage-any", 
-                    profile_deep_coverage_any).
+long_option("profile-deep-coverage-after-goal",
+                    profile_deep_coverage_after_goal).
 long_option("profile-deep-coverage-branch-ite",
                     profile_deep_coverage_branch_ite).
 long_option("profile-deep-coverage-branch-switch",
Index: deep_profiler/create_report.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/create_report.m,v
retrieving revision 1.9
diff -u -p -b -r1.9 create_report.m
--- deep_profiler/create_report.m	17 Sep 2008 03:26:29 -0000	1.9
+++ deep_profiler/create_report.m	20 Sep 2008 10:48:12 -0000
@@ -592,10 +592,7 @@ create_cs_summary_add_to_map(Deep, CSSta
 add_coverage_point_to_map(CoveragePoint, !SolnsMap, !BranchMap) :-
     CoveragePoint = coverage_point(_, GoalPath, CPType),
     (
-        ( CPType = cp_type_solns_may_fail
-        ; CPType = cp_type_solns_multi
-        ; CPType = cp_type_solns_any
-        ),
+        CPType = cp_type_coverage_after,
         svmap.det_insert(GoalPath, CoveragePoint, !SolnsMap)
     ;
         CPType = cp_type_branch_arm,
Index: mdbcomp/program_representation.m
===================================================================
RCS file: /home/mercury1/repository/mercury/mdbcomp/program_representation.m,v
retrieving revision 1.37
diff -u -p -b -r1.37 program_representation.m
--- mdbcomp/program_representation.m	9 Sep 2008 01:37:31 -0000	1.37
+++ mdbcomp/program_representation.m	20 Sep 2008 10:28:52 -0000
@@ -620,12 +620,10 @@
             ).
 
 % This enumeration specifies the type of coverage point.  A branch arm is an
-% arm of an if-then-else, switch or disj goal, the type can be determined by
-% the goal_path above.
+% arm of an if-then-else, switch or disj goal.  The coverage_after type is used
+% to measure the coverage after the goal it's coverage point referrs to.
 :- type cp_type
-    --->    cp_type_solns_may_fail
-    ;       cp_type_solns_multi
-    ;       cp_type_solns_any
+    --->    cp_type_coverage_after
     ;       cp_type_branch_arm.
 
 
@@ -1688,17 +1686,13 @@ pred_is_external("backjump", "builtin_ba
 % section.
 %
 
-coverage_point_type_c_value(cp_type_solns_may_fail,
-    "MR_cp_type_solns_may_fail").
-coverage_point_type_c_value(cp_type_solns_multi, "MR_cp_type_solns_multi").
-coverage_point_type_c_value(cp_type_solns_any, "MR_cp_type_solns_any").
+coverage_point_type_c_value(cp_type_coverage_after, 
+    "MR_cp_type_coverage_after").
 coverage_point_type_c_value(cp_type_branch_arm, "MR_cp_type_branch_arm").
 
 :- pragma foreign_enum("C", cp_type/0,
     [
-        cp_type_solns_may_fail - "MR_cp_type_solns_may_fail",
-        cp_type_solns_multi    - "MR_cp_type_solns_multi",
-        cp_type_solns_any      - "MR_cp_type_solns_any",
+        cp_type_coverage_after  - "MR_cp_type_coverage_after",
         cp_type_branch_arm     - "MR_cp_type_branch_arm"
     ]).
 
Index: runtime/mercury_deep_profiling.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_profiling.h,v
retrieving revision 1.20
diff -u -p -b -r1.20 mercury_deep_profiling.h
--- runtime/mercury_deep_profiling.h	3 Sep 2008 04:08:41 -0000	1.20
+++ runtime/mercury_deep_profiling.h	20 Sep 2008 10:29:25 -0000
@@ -60,9 +60,7 @@ struct MR_ProfilingMetrics_Struct {
 ** mdbcomp/program_representation.m when updating this structure.
 */
 typedef enum {
-	MR_cp_type_solns_may_fail,
-	MR_cp_type_solns_multi,
-	MR_cp_type_solns_any,
+	MR_cp_type_coverage_after,
 	MR_cp_type_branch_arm
 } MR_CPType; 
 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20080920/04186697/attachment.sig>


More information about the reviews mailing list