Commit Graph

5 Commits

Author SHA1 Message Date
Zoltan Somogyi
753fe25c90 Put the later parts of .*opt files in a standard order.
compiler/intermod.m:
    We used to put predicate declarations and definitions into .opt files
    in order of pred_id. Since pred_ids are allocated sequentially, this
    meant that the order of the pragmas in .*opt files recording analysis
    results was determined by the order of the predicate declarations
    in the .m file, and if this changes, everything that depends on the
    .opt file has to be recompiled. Change this to put the pragmas into
    an order based on the predicates' names, arities, and pred_or_func flag.

    Precede each block of analysis results (one block per pragma type)
    with a blank line, to make .*opt files a bit easier to read by revealing
    their structure.

    When printing analysis results for all the procedures of a predicate,
    don't get a list of proc_ids and then look them up one by one; just
    iterated over all the proc_infos in the proc_table.

    Rename some predicates to make their names fit into the naming scheme
    used in the rest of the module.

compiler/hlds_module.m:
compiler/hlds_pred.m:
    The results of the exception, trailing and mm_tabling analyses
    used to be stored in the module_info as maps from pred_proc_ids
    to the results about the procedure. Change this to store them
    in the proc_info of the procedure, since any code that looks up
    the results of an analysis typically also wants to look up other
    information in the proc_info as well. (intermod.m certainly does.)

    The results of the termination, structure sharing and structure reuse
    analysis were already stored in the proc_info.

compiler/add_pragma.m:
    When reading in exceptions, trailing and mm_tabling pragmas,
    add their information to the named procedure's proc_info,
    not to a map in the module_info.

compiler/exception_analysis.m:
compiler/tabling_analysis.m:
compiler/trailing_analysis.m:
    Put analysis results into procedures' proc_infos, not into a map
    in the module_info, and if need be, look it up there as well.

compiler/goal_form.m:
    Look up the results of exception_analysis in procedures' proc_infos,
    not in a map in the module_info.

compiler/lco.m:
    Work around a bug in lco.m itself exposed by the move of analysis
    results to proc_infos. When lco.m duplicates the proc_info of a procedure
    that it optimizes, it now duplicates its analysis results as well.
    The duplication is correct in a sense, since any results of the exception,
    trailing and mm_tabling analysis that hold for the original procedure
    have to hold for the duplicate copy as well, but interestingly, this extra
    precision causes simplify to believe that the call from the original
    procedure to duplicated procedure is dead code that can be eliminated,
    since it is det and appears to have no outputs. In fact, it does have
    outputs, but it returns those outputs via impure calls to store_at_ref.
    While the call to store_at_ref in the duplicated procedure is marked
    as impure, the call to the duplicate procedure in the original procedure
    is NOT (yet) so marked.

compiler/parse_tree_out_pred_decl.m:
    When printing parts of predicate declarations, e.g. as parts of pragmas
    that record analysis results, don't take as an argument a context that
    will never be used.

compiler/add_clause.m:
compiler/dependency_graph.m:
compiler/hlds_out_pred.m:
compiler/make_hlds_error.m:
compiler/mode_errors.m:
compiler/parse_tree_out.m:
compiler/parse_tree_out_pragma.m:
compiler/typecheck.m:
    Conform to the changes in parse_tree_out_pred_decl.m above.

tests/term/*.trans_opt_exp:
    Expect the same termination analysis results as before, just in
    predicate name order, and with a blank line before each block.
2015-09-16 10:45:05 +10:00
Julien Fischer
864bfa2c58 Update the expected outputs of these test cases.
Estimated hours taken: 0.1
Branches: main

tests/term/*.trans_opt_exp:
	Update the expected outputs of these test cases.
	These have changed because of the recent change
	to termination2_info pragmas.
2005-07-15 08:11:58 +00:00
Julien Fischer
0323bb2c6d Fix recent test case failures in the term directory.
Estimated hours taken: 1
Branches: main

Fix recent test case failures in the term directory.  The test case
failures were caused by the argument size constraints being in a
different order to the expected outputs in some grades.  (The change
in the ordering is due to differences in the HLDS in each grade.)

Also, fix an additional problem where non-negativity constraints
where being written out as part of the termination2_info pragmas.
This is unnecessary as the analyser assumes that variables are
non-negative anyway.

compiler/term_constr_main.m:
	When writing out argument size constraints in the termination2_info
	pragmas, make sure that we don't write out non-negativity
	constraints.

	Sort the constraint set before writing it out to the
	termination2_info pragmas.

tests/term/*.trans_opt_exp.m:
	Minor changes to conform to the above.
2005-06-07 11:30:31 +00:00
Julien Fischer
3eb66b2b12 Enable the support for writing out termination2_info pragmas
Estimated hours taken: 1
Branches: main

Enable the support for writing out termination2_info pragmas
in the .opt and .trans_opt files.

Test both termination analyses when running the test suite.

compiler/term_constr_main.m:
compiler/trans_opt.m:
	Uncomment the code that causes termination2_info pragmas
	to be written out the .opt and .trans_opt files.

tests/term/Mmakefile:
	Run the new termination analyser on these tests as well.

tests/term/*.trans_opt_exp:
	Include the expected termination2_info pragmas.
2005-06-03 15:59:48 +00:00
Julien Fischer
acc6161006 Fix a bug in the termination analysis that causes a software error
Estimated hours taken: 10
Branches: main

Fix a bug in the termination analysis that causes a software error
during pass 2.  This is due to a sanity check failing.

The bug in pass 1 occurred when the analyser detected a call to a procedure
that had an infinite change constant.  If the call affected the size
of any of the variables in the caller then the analyser marked it as an
error and aborted the remainder of pass 1.  Any other procedures in the
SCC were not checked and their change constant was set to infinite.

The analyser did not (correctly) consider a infinite change constant to be a
fatal error, ie. one that would result in nontermination, so it ran pass 2.
However, since the remainder of the SCC had not been analysed during pass 1
it had not been determined if any of those procedures made calls to
procedures that had been marked as nonterminating.  Pass 2 assumes the
opposite, namely that any SCC that is analysing will contain no calls
to procedures that have been marked as nonterminating since pass 1
should have detected this.

This diff fixes that problem by checking the remainder of the SCC for
nonterminating calls if the usual pass 1 is aborted.

compiler/term_pass1.m:
	Make sure that all of the SCC is checked for calls to nonterminating
	procedures when the analysis is abandoned due to a non-fatal error.

	Add a comment about why this is necessary.

	Add an end_module declaration.

compiler/term_pass2.m:
	Document some assumptions that this module makes.

compiler/term_traversal:
	Fix some formatting.

tests/term/Mmakefile:
tests/term/Mercury.options:
tests/term/inf_const_bug.m:
tests/term/inf_const_bug.trans_opt_exp
	Add a new test case.
2003-12-15 07:11:06 +00:00