[m-rev.] for review: intermodule analysis fixes

Peter Wang wangp at students.cs.mu.OZ.AU
Tue Feb 21 15:39:04 AEDT 2006


This should allow the compiler to be built with --intermodule-analysis
again.


Estimated hours taken: 10
Branches: main

compiler/make.program_target.m:
	Don't try to reanalyse suboptimal, non-local modules when using
	`--intermodule-analysis'.

compiler/exception_analysis.m:
compiler/trailing_analysis.m:
compiler/unused_args.m:
	When looking up an analysis result, if the result came from a non-local
	module and is `suboptimal', just assume it is `optimal' since we can't
	make requests to or reanalyse the non-local module anyway.  On the
	other hand, if we look up a result from a local module which doesn't
	yet exist, record the default (suboptimal) result that we are using
	into the module's analysis registry, so that when the module is
	reanalysed, if the answer pattern changes we will know that it changed
	and the modules which made use of the default result can be marked.

Index: compiler/exception_analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/exception_analysis.m,v
retrieving revision 1.20
diff -u -r1.20 exception_analysis.m
--- compiler/exception_analysis.m	16 Feb 2006 05:48:29 -0000	1.20
+++ compiler/exception_analysis.m	20 Feb 2006 04:57:35 -0000
@@ -1015,16 +1015,27 @@
         MaybeBestStatus = no,
         % If we do not have any information about the callee procedure then
         % assume that it throws an exception.
-        top(Call) = exception_analysis_answer(Result),
-        AnalysisStatus = suboptimal,
+        top(Call) = Answer,
+        Answer = exception_analysis_answer(Result),
+        module_is_local(mmc, ModuleId, IsLocal, !IO),
         (
-            MakeAnalysisRegistry = yes,
-            record_request(analysis_name, ModuleId, FuncId, Call,
-                !AnalysisInfo),
-            record_dependencies(ModuleId, FuncId, Call, ModuleInfo, CallerSCC,
-                !AnalysisInfo)
+            IsLocal = yes,
+            AnalysisStatus = suboptimal,
+            (
+                MakeAnalysisRegistry = yes,
+                analysis.record_result(ModuleId, FuncId,
+                    Call, Answer, AnalysisStatus, !AnalysisInfo),
+                analysis.record_request(analysis_name, ModuleId, FuncId, Call,
+                    !AnalysisInfo),
+                record_dependencies(ModuleId, FuncId, Call,
+                    ModuleInfo, CallerSCC, !AnalysisInfo)
+            ;
+                MakeAnalysisRegistry = no
+            )
         ;
-            MakeAnalysisRegistry = no
+            IsLocal = no,
+            % We can't do any better anyway.
+            AnalysisStatus = optimal
         )
     ).
 
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.44
diff -u -r1.44 make.program_target.m
--- compiler/make.program_target.m	13 Feb 2006 07:57:21 -0000	1.44
+++ compiler/make.program_target.m	21 Feb 2006 04:09:46 -0000
@@ -619,7 +619,9 @@
         Succeeded = no
     ;
         reverse_ordered_modules(!.Info ^ module_dependencies,
-            TargetModules0, TargetModules),
+            TargetModules0, TargetModules1),
+        list.filter((pred(Mod::in) is semidet :- list.member(Mod, AllModules)),
+            TargetModules1, TargetModules),
         make_local_module_id_options(MainModuleName, Succeeded1,
             LocalModulesOpts, !Info, !IO),
         (
Index: compiler/trailing_analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trailing_analysis.m,v
retrieving revision 1.7
diff -u -r1.7 trailing_analysis.m
--- compiler/trailing_analysis.m	16 Feb 2006 06:21:41 -0000	1.7
+++ compiler/trailing_analysis.m	20 Feb 2006 04:48:54 -0000
@@ -1165,16 +1165,27 @@
         MaybeBestStatus = no,
         % If we do not have any information about the callee procedure
         % then assume that it modifies the trail.
-        top(Call) = trailing_analysis_answer(Result),
-        AnalysisStatus = suboptimal,
+        top(Call) = Answer,
+        Answer = trailing_analysis_answer(Result),
+        module_is_local(mmc, ModuleId, IsLocal, !IO),
         (
-            MakeAnalysisRegistry = yes,
-            analysis.record_request(analysis_name, ModuleId, FuncId, Call,
-                !AnalysisInfo),
-            record_dependencies(ModuleId, FuncId, Call,
-                ModuleInfo, CallerSCC, !AnalysisInfo)
+            IsLocal = yes,
+            AnalysisStatus = suboptimal,
+            (
+                MakeAnalysisRegistry = yes,
+                analysis.record_result(ModuleId, FuncId,
+                    Call, Answer, AnalysisStatus, !AnalysisInfo),
+                analysis.record_request(analysis_name, ModuleId, FuncId, Call,
+                    !AnalysisInfo),
+                record_dependencies(ModuleId, FuncId, Call,
+                    ModuleInfo, CallerSCC, !AnalysisInfo)
+            ;
+                MakeAnalysisRegistry = no
+            )
         ;
-            MakeAnalysisRegistry = no
+            IsLocal = no,
+            % We can't do any better anyway.
+            AnalysisStatus = optimal
         )
     ).
 
Index: compiler/unused_args.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unused_args.m,v
retrieving revision 1.119
diff -u -r1.119 unused_args.m
--- compiler/unused_args.m	14 Feb 2006 07:24:50 -0000	1.119
+++ compiler/unused_args.m	21 Feb 2006 04:04:28 -0000
@@ -437,15 +437,25 @@
                 AnalysisInfo = AnalysisInfo1
             ;
                 MaybeBestResult = no,
-                % XXX makes too many requests
-                globals__io_lookup_bool_option(make_analysis_registry,
-                    MakeAnalysisRegistry, !IO),
+                module_is_local(mmc, PredModuleId, IsLocal, !IO),
                 (
-                    MakeAnalysisRegistry = yes,
-                    analysis.record_request(analysis_name, PredModuleId, 
-                        FuncId, Call, AnalysisInfo1, AnalysisInfo)
+                    IsLocal = yes,
+                    % XXX makes too many requests
+                    globals__io_lookup_bool_option(make_analysis_registry,
+                        MakeAnalysisRegistry, !IO),
+                    (
+                        MakeAnalysisRegistry = yes,
+                        analysis.record_result(PredModuleId, FuncId,
+                            Call, top(Call) : unused_args_answer, suboptimal,
+                            AnalysisInfo1, AnalysisInfo2),
+                        analysis.record_request(analysis_name, PredModuleId, 
+                            FuncId, Call, AnalysisInfo2, AnalysisInfo)
+                    ;
+                        MakeAnalysisRegistry = no,
+                        AnalysisInfo = AnalysisInfo1
+                    )
                 ;
-                    MakeAnalysisRegistry = no,
+                    IsLocal = no,
                     AnalysisInfo = AnalysisInfo1
                 )
             ),
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list