mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-06 07:49:02 +00:00
compiler/instmap.m:
Before code generation, the MLDS backend recomputes all nonlocal sets,
because the MLDS code generator needs them to contain exact information,
but the compiler's rules allow the nonlocal sets in goal_infos
to overapproximate the true nonlocals set. Since instmap_deltas can
contain a variable as a key only if that variable is in the nonlocals set,
this also involved calling instmap_delta_restrict to ensure this.
However, while the nonlocals sets of goal_infos *may* include variables
that are not true nonlocals, they typically do not do so. This diff
adds conditionally-enabled code to record information about this,
and the results show that 90+% of calls to instmap_delta_restrict
make no changes to the instmap_delta. This diff therefore also
special-cases the handling of such calls. The reason why I believe
this to be worthwhile is that in a deep profiled compiler run,
I observed that the instmap_delta_restrict predicate accounted for
about 1.4% of the call counts, and about 1.3% of the memory allocated.
library/map.m:
library/tree234.m:
Add the library predicates needed by the special case code.
Use predmode declarations in some other places.
NEWS:
Mention the new library predicates.
compiler/mercury_compile_main.m:
Invoke the predicate in instmap.m that, if statistics collection
was enabled, appends its results to a file.
tools/restrict_stats:
A script to summarize the contents of that file.
27 lines
938 B
Awk
Executable File
27 lines
938 B
Awk
Executable File
#!/usr/bin/awk -f
|
|
# vim: ft=awk ts=4 sw=4 et
|
|
NF == 4 {
|
|
count_same += $1;
|
|
count_changed += $2;
|
|
total_before += $3;
|
|
total_after += $4;
|
|
}
|
|
END {
|
|
count = count_same + count_changed;
|
|
percent_same = (100 * count_same) / count;
|
|
percent_changed = (100 * count_changed) / count;
|
|
printf "calls with no change: %8d (%5.2f%%)\n",
|
|
count_same, percent_same;
|
|
printf "calls with changes: %8d (%5.2f%%)\n",
|
|
count_changed, percent_changed;
|
|
|
|
printf "\n";
|
|
printf "calls with changes:\n";
|
|
printf "number of vars before: %8d\n", total_before;
|
|
printf "number of vars after: %8d\n", total_after;
|
|
printf "percentage left after: %5.2f%%\n",
|
|
((100 * total_after) / total_before);
|
|
printf "percentage deleted: %5.2f%%\n",
|
|
((100 * (total_before - total_after)) / total_before);
|
|
}
|