[m-rev.] diff: sanity check for sharing analysis

Peter Wang novalazy at gmail.com
Fri Jun 13 11:04:18 AEST 2008


Branches: main

compiler/structure_sharing.analysis.m:
	Abort if structure sharing analysis of an SCC is taking too long.

Index: compiler/structure_sharing.analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/structure_sharing.analysis.m,v
retrieving revision 1.37
diff -u -p -r1.37 structure_sharing.analysis.m
--- compiler/structure_sharing.analysis.m	6 Jun 2008 02:18:06 -0000	1.37
+++ compiler/structure_sharing.analysis.m	13 Jun 2008 01:01:45 -0000
@@ -88,6 +88,7 @@
 :- import_module transform_hlds.mmc_analysis.
 
 :- import_module bool.
+:- import_module int.
 :- import_module list.
 :- import_module map.
 :- import_module maybe.
@@ -443,6 +444,16 @@ analyse_scc(ModuleInfo, SCC, !SharingTab
 
 analyse_scc_until_fixpoint(ModuleInfo, SCC, SharingTable,
         !FixpointTable, !DepProcs, !IO) :-
+    % Abort if the analysis is taking too long.  It's probably a bug.
+    Run = ss_fixpoint_table_which_run(!.FixpointTable),
+    ( Run > max_runs ->
+        unexpected(this_file,
+            "analyse_scc_until_fixpoint: fixpoint not reached after "
+            ++ string.from_int(max_runs) ++ " runs")
+    ;
+        true
+    ),
+
     list.foldl3(analyse_pred_proc(ModuleInfo, SharingTable), SCC,
         !FixpointTable, !DepProcs, !IO),
     ( ss_fixpoint_table_stable(!.FixpointTable) ->
@@ -453,6 +464,10 @@ analyse_scc_until_fixpoint(ModuleInfo, S
             !FixpointTable, !DepProcs, !IO)
     ).
 
+:- func max_runs = int.
+
+max_runs = 100.
+
 %-----------------------------------------------------------------------------%
 %
 % Perform structure sharing analysis on a procedure


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