[m-rev.] diff: fix bug with intermodule analysis and unused args opt

Julien Fischer juliensf at csse.unimelb.edu.au
Tue Jul 18 13:48:37 AEST 2006


Estimated hours taken: 1
Branches: main, release

Fix a bug with --intermodule-analysis and unused-argument optimization.

compiler/unused_args.m:
 	Don't initially record sub-optimal answers for compiler generated
 	unification and comparison predicates to the analysis registry.
 	This results in spurious entries for these predicates in the
 	registry because the rest of the analysis does not record results
 	for them.

compiler/mmc_analysis.m:
analysis/analysis.m:
 	Fix some formatting.

Julien.

Index: analysis/analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/analysis/analysis.m,v
retrieving revision 1.7
diff -u -r1.7 analysis.m
--- analysis/analysis.m	29 Mar 2006 08:06:29 -0000	1.7
+++ analysis/analysis.m	17 Jul 2006 08:24:51 -0000
@@ -5,8 +5,9 @@
  % This file may only be copied under the terms of the GNU Library General
  % Public License - see the file COPYING.LIB in the Mercury distribution.
  %-----------------------------------------------------------------------------%
-% File: analysis.m
-% Main authors: stayl, wangp
+%
+% File: analysis.m.
+% Main authors: stayl, wangp.
  %
  % An inter-module analysis framework, as described in
  %
@@ -16,6 +17,7 @@
  %	<http://www.cl.cam.ac.uk/~njn25/pubs/masters2001.ps.gz>.
  %
  %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%

  :- module analysis.
  :- interface.
@@ -38,13 +40,16 @@
  	func compiler_name(Compiler) = string,

  	% Describe the analyses which can be performed by a compiler.
+	%
  	func analyses(Compiler, analysis_name) = analysis_type is semidet,

  	% module_id_to_read_file_name(Compiler, ModuleId, Ext, FileName)
+	%
  	pred module_id_to_read_file_name(Compiler::in, module_id::in,
  		string::in, maybe_error(string)::out, io::di, io::uo) is det,

  	% module_id_to_write_file_name(Compiler, ModuleId, Ext, FileName)
+	%
  	pred module_id_to_write_file_name(Compiler::in, module_id::in,
  		string::in, string::out, io::di, io::uo) is det,

Index: compiler/mmc_analysis.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mmc_analysis.m,v
retrieving revision 1.17
diff -u -r1.17 mmc_analysis.m
--- compiler/mmc_analysis.m	5 Jun 2006 02:26:08 -0000	1.17
+++ compiler/mmc_analysis.m	17 Jul 2006 08:24:06 -0000
@@ -5,13 +5,14 @@
  % This file may only be copied under the terms of the GNU General
  % Public License - see the file COPYING in the Mercury distribution.
  %-----------------------------------------------------------------------------%
-
-% File: mmc_analysis.m
-% Main author: stayl
-
+% 
+% File: mmc_analysis.m.
+% Main author: stayl.
+%
  % Specify Mercury compiler analyses to be used with the inter-module analysis
  % framework.
-
+% 
+%-----------------------------------------------------------------------------%
  %-----------------------------------------------------------------------------%

  :- module transform_hlds.mmc_analysis.
Index: compiler/unused_args.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unused_args.m,v
retrieving revision 1.127
diff -u -r1.127 unused_args.m
--- compiler/unused_args.m	29 Mar 2006 08:07:29 -0000	1.127
+++ compiler/unused_args.m	17 Jul 2006 08:37:24 -0000
@@ -5,10 +5,10 @@
  % This file may only be copied under the terms of the GNU General
  % Public License - see the file COPYING in the Mercury distribution.
  %-----------------------------------------------------------------------------%
-
+%
  % File: unused_args.m.
  % Main author: stayl.
-
+%
  % Detects and removes unused input arguments in procedures, especially
  % type_infos.
  %
@@ -41,7 +41,8 @@
  %
  % The predicates are then fixed up. Unused variables and unifications are
  % removed.
-
+% 
+%-----------------------------------------------------------------------------%
  %-----------------------------------------------------------------------------%

  :- module transform_hlds.unused_args.
@@ -448,11 +449,16 @@
                          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)
+                        ( not is_unify_or_compare_pred(PredInfo) ->
+                            analysis.record_result(PredModuleId, FuncId,
+                                Call, top(Call) : unused_args_answer,
+                                suboptimal, AnalysisInfo1, AnalysisInfo2),
+                            analysis.record_request(analysis_name,
+                                PredModuleId, FuncId, Call, AnalysisInfo2,
+                                AnalysisInfo)
+                        ;
+                            AnalysisInfo = AnalysisInfo1
+                        )
                      ;
                          MakeAnalysisRegistry = no,
                          AnalysisInfo = AnalysisInfo1
@@ -1688,8 +1694,9 @@
  %-----------------------------------------------------------------------------%

      % Except for type_infos, all args that are unused in one mode of a
-    % predicate should be unused in all of the modes of a predicate, so we only
-    % need to put out one warning for each predicate.
+    % predicate should be unused in all of the modes of a predicate, so we
+    % only need to put out one warning for each predicate.
+    %
  :- pred output_warnings_and_pragmas(module_info::in, unused_arg_info::in,
      maybe(io.output_stream)::in, bool::in, pred_proc_list::in,
      set(pred_id)::in, io::di, io::uo) is det.

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at csse.unimelb.edu.au
administrative address: owner-mercury-reviews at csse.unimelb.edu.au
unsubscribe: Address: mercury-reviews-request at csse.unimelb.edu.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at csse.unimelb.edu.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list