Fix a problem that arises in the deep profiler if the program being profiled
was using both intermodule optimization and inlining. The issue was that
even though runtime/mercury_deep_profiling.c had access, for every call site
to the full context of that call site, containing both the file name and
the line number, it wrote out *only* the line number. The deep profiler
then got the file name from the file name stored in the proc_static structure
of the procedure containing the call site.
This works very close to 100% of the time, because
- user-written programs just about never use ":- pragma source_file", and
- in the absence of such pragmas, all the goals in a procedure will be
from the same file as the procedure's context.
However, if
- a call site calls a procedure in another module,
- the compiler has access to the code of that procedure from a .opt file, and
- the compiler decides to inline that call,
then the call, whose context is in the original source file, will be replaced
by the code of the procedure from the .opt file, whose context will NOT have
the same file name. Any description of this call site will list
- the code from the .opt file (such as the callee's callee),
- the file name from the original source file, and
- the line number from the .opt file.
This mismatch is very confusing, which is why this diff fixes it.
runtime/mercury_deep_profiling.c:
Fix this by writing out the file name part, as well as the line number
part, of each call site. The space impact is not as big as one might
expect, because compiler/deep_profiling.m already had an optimization
that set the filename part of each call site context to the empty string
if it was identical to the context of the procedure. Therefore for all
call sites that do NOT exhibit the bug that this diff fixes, the space
cost is only a single NULL character in the profiling data file.
Since this IS a change in the file format, bump the format version number
from 8 to 9.
deep_profiler/profile.m:
deep_profiler/read_profile.m:
Handle reading in both version 8 and version 9 profiling data files.
deep_profiler/create_report.m:
When creating descriptions of call sites, use the call site's filename
if it is not the empty string; if it is the empty string, then use
the containing procedure's file name, as we have done all along.
deep_profiler/display_report.m:
deep_profiler/dump.m:
deep_profiler/report.m:
Dump the new field in commands intended only for implementors.
deep_profiler/startup.m:
Conform to the changes above.