A method, system, and program product for optimizing compilation. In the preferred
embodiment, a compiler compiles a source-code file twice; once to gather register-pressure
data, and a second time to apply the data. Thus, the compiler saves register-pressure
data during the first compilation and uses it during the second compilation to
make informed inlining decisions. The compiler saves two kinds of data during the
first compilation: (1) the maximum register-pressure occurring in each procedure;
and (2) within each procedure, the register pressure at each call site that is
a potential inlining candidate. This data is then fed into the compiler during
the second compilation. The compiler uses the data during the second compilation
in two ways. First, when deciding whether to inline a child procedure into a parent
procedure, the compiler determines whether the sum of the maximum register-pressure
and the site register-pressure exceeds the number of available, physical registers.
If so, the inlining is not done. Otherwise, inlining is permitted subject to other
heuristics. Second, if the child procedure is chosen for inlining into the parent
procedure, the maximum register-pressure of the parent procedure is set to be the
maximum of its existing value or the sum of the maximum register-pressure of the
child procedure and the site register-pressure. This assures that later consideration
of the parent procedure for inlining into another procedure can be done with accurate
register-pressure data available.