Mercury Bugs - mercury | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0000506 | mercury | Feature Request | public | 2020-05-01 17:22 | 2020-05-01 17:23 |
Reporter | zs | ||||
---|---|---|---|---|---|
Assigned To | zs | ||||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | assigned | Resolution | open | ||
Platform | OS | OS Version | |||
Product Version | |||||
Target Version | Fixed in Version | ||||
Summary | 0000506: --recommend-order | ||||
Description | It would be nice if the compiler could recommend an order for the predicates (and functions) defined in a module. The order I am thinking of having the compiler recommend would be computed as: - Compute the SCCs of predicate call graph, each SCC containing a set of mutually recursive predicates. - Compute the dependencies between SCCs as a tree that the following steps flatten to a list that is *consistent* with the tree, in the sense that if SCC A contains a call to something in SCC B, then have SCC A appear before SCC B in the list of SCCs. - If the module contains N exported predicates, named e.g. Exported1 through ExportedN, the compute the call tree of each exported predicate. (Consider each set of mutually-recursive exported predicates to be just one exported predicate, for simplicity of exposition in the following.) By the definition of SCCs, each call tree will contain either all the predicates in an SCC or none of them, so we can speak of each call tree as being composed of SCCs. Partition the SCCs into N+1 partitions, with partition I consisting of the SCCs that part of the call tree of *only* ExportedI, with the last partition consisting of the SCCs that are part of the call tree of more than one exported predicate. Put all the SCCs in each partition before all the SCCs in any later partitions. - In each of the first N partitions, put the one containing the exported predicate(s) first. - If the relative order of two SCCs in a partition is not determined by the rules above, order them by the line number of the context where the first reference to them occurs. (This may be a call to a predicate in the SCC, or the construction of a closure containing a reference to such a predicate.) This should yield a complete order of the SCCs that do contains some reference to them. The SCCs that have no such references contain dead code, and they should be reported as such. - Within each non-dead SCC, put the exported predicates (if any) first, in order of the line numbers of their declarations. The nonexported predicates should follow, in the order of the line numbers of the first references to them. This should establish a complete order among the non-dead predicates. | ||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files |
There are no notes attached to this issue. |
Issue History | |||||
Date Modified | Username | Field | Change | ||
---|---|---|---|---|---|
2020-05-01 17:22 | zs | New Issue | |||
2020-05-01 17:23 | zs | Assigned To | => zs | ||
2020-05-01 17:23 | zs | Status | new => assigned |