[m-rev.] for review: more analysis framework fixes/changes

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Jun 5 14:17:07 AEST 2008


On Tue, 3 Jun 2008, Peter Wang wrote:

> Branches: main
>
> More changes to the intermodule analysis framework.  This patch mainly deals
> with incorrect treatment of :- external procedures, opt_imported procedures,
> and forcing the correct reanalyses when answers change or requests are
> satisfied.
>
> - Previously, the way to ensure that a module M is reanalysed if a request in
>  module N is satisfied was, while analysing M: assume an answer for the
>  procedure in N; record that as a result in N; and record that M has a
>  dependency on that answer.  When N is analysed, if the real answer is
>  better than the assumed answer, M would be marked `suboptimal' and later
>  reanalysed.
>
>  That's complicated and wasn't always done correctly.  Now we remember the
>  module which makes a request.  When the request is satisfied, we mark the
>  requesting module as `suboptimal'.  This also means the `.analysis' file of
>  a module will only be modified when analysing that module and no others,
>  which should be useful for parallel builds.
>
> - In most analyses we weren't recording results for exported `:- external'
>  procedures as we don't have their clauses and don't analyse them.  Other
>  modules would happily make requests for `:- external' procedures, which
>  would never be satisfied.
>
> - We shouldn't make intermodule requests for `opt_imported' procedures as we
>  actually have their clauses.  Even if the request is satisfied, we'd
>  probably not look them up since we do have their clauses.
>
> - If a module M opt_imports a procedure P from module N (its clauses are
>  available while analysing M) then M also needs to depend on any answers
>  required by P.  Otherwise a change to an answer required by P won't cause M
>  to be reanalysed.
>
> - There doesn't seem to be any reason to keep track of the analysis status of
>  individual results.  If an answer changes requiring another module to be
>  reanalysed, the *whole module* will be marked suboptimal or invalid.  And
>  if that results in changed answers, its dependant modules will be marked.
>  This patch doesn't remove the status of individual results but makes them
>  always `optimal'.

If keeping the existing support for the individual results is not to
much bother then we should retain it (for now) -- if it is too much bother it
should probably just be removed.  I can't see us moving beyond module
level granularity for this in the immediate future.

> compiler/analysis.m:
> 	Remember the name of the module being analysed in the analysis_info.
> 	Simplify some predicate interfaces with this information.
>
> 	Remember whether we're currently making an analysis file or just
> 	reading from them.  Make the record_* predicates do nothing in the
> 	latter case, so the caller doesn't need to check.  Also make the
> 	record predicates do the right thing if the callee module is
> 	non-local, e.g.  don't make requests to non-local modules.
>
> 	Automatically add a request if depending on a result that doesn't
> 	exist.
>
> 	Add a procedure to return the existing call patterns for a procedure,
> 	regardless of whether the module has been marked `invalid'.
>
> 	Add some assertions to check the analysis framework is being used as
> 	intended.
>
> 	Minor cleanups.
>
> compiler/analysis.file.m:
> 	Record the module that made the request in `.request' files.
>
> 	Bump the analysis file version number.
>
> compiler/hlds_module.m:
> 	Pass extra arguments to `init_analysis_info'.
>
> compiler/hlds_pred.m:
> 	Add `pred_info_is_imported_not_external' which doesn't succeed on
> 	`:- external' procedures (defined in the current module), unlike
> 	`pred_info_is_imported'.
>
> compiler/exception_analysis.m:
> compiler/tabling_analysis.m:
> compiler/trailing_analysis.m:
> compiler/unused_args.m:
> 	Record results for `:- external' procedures.
>
> 	Don't look up results for our own `:- external' procedures from the
> 	analysis registry.  In general, fix many spots where external procs
> 	would be treated as imported.
>
> 	Write out results for procedures which are exported to submodules.
>
> 	Conform to analysis framework changes.  Remove some redundant checks
> 	which have been moved into the framework.
>
> compiler/mercury_compile.m:
> 	Conform to analysis framework changes.
>
> compiler/structure_reuse.analysis.m:
> 	Be careful not to read in requests and call patterns for
> 	`opt_imported' procedures as if they were defined in the current
> 	module.
>
> 	If depending on an answer that doesn't exist, also make a request for
> 	that answer.
>
> 	Conform to analysis framework changes.
>
> 	Write out messages when removing useless reuse version procedures.
>
> compiler/structure_reuse.indirect.m:
> 	Use `pred_info_is_imported_not_external' so as not to look up results
> 	for our own `:- external' procedures from the analysis registry.
>
> 	Treat `opt_imported' procedures as intra-module as far as requests
> 	are concerned.  We need to satisfy requests for them in the current
> 	compiler invocation rather than when analysing imported modules.
>
> compiler/structure_sharing.analysis.m:
> 	Fix treatment of `:- external' procedures.
>
> 	Conform to analysis framework changes.
>
> compiler/structure_sharing.domain.m:
> 	Don't return suboptimal when unable to look up a result.
>
> compiler/mmc_analysis.m:
> 	Replace pred_or_func_name_arity_to_func_id by a higher-level
> 	predicate.

The diff looks fine (although I haven't looked all that closely).

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