The invention enables a compiler (during its first compilation pass) to
insert identifiers during an early optimization phase into
machine-independent code. The identifiers are used for identifying
specific instructions of the machine-independent code. The compiler may
use a table to record the assignment of identifiers and their
corresponding portion of machine-independent code. During subsequent
optimization phases of the first compilation pass, portions of
machine-independent code are transformed into portions of
machine-dependent code, and the machine-dependent code inherits
identification associated with the portions of machine-independent code
that were used to generate the portions of machine-dependent code. After
the first compilation pass, executable code is made to interact with test
data to generate statistical execution data which is collected by
previously inserted counters. The collected counter data is consolidated
so that it relates to the instructions of the machine-independent code.
During a second compilation pass of the compiler, the compiler reads the
machine-independent code, the collected or captured counter data, an
indication of the association between the identifiers and the
instructions (which can be stored in a table). Subsequently, the compiler
begins locating instructions of the machine-independent code relative to
other instructions of the machine-independent code during an early or
first optimization phase of the second compilation pass.