Patent ID: 11886848
Assignee: INTERNATIONAL BUSINESS MACHINES CORPORATION
Field: Computer technology (Electrical engineering)
Classification: CPC G | IPC G

Claim 17:
18. A computer-implemented method for binary translation combining raw binary code and compiler-produced metadata, the computer-implemented method comprising:
in response to receiving original compiler-produced control flow information including descriptive binary data comprising basic blocks in an original intermediate representation (IR), with start and end original machine instruction offsets corresponding to each respective block, edges between these basic blocks in the original IR, out-of-line basic blocks for late created control flow, and information available to the original compiler on calls which never return, reconciling the original compiler-produced control flow information with how lower level machine instructions make up a control flow in raw binary code by:
creating, by a binary translator using the descriptive binary data from original compiler-produced modules, progressively splitting basic blocks to be used during optimization and code generation phases of the binary translator by:
splitting machine instructions using information about the basic blocks in the original IR and out-of-line basic blocks in the descriptive binary data;
splitting the machine instructions further by analyzing branch instructions in the raw binary code in each IR-based basic block; and
splitting the machine instructions further at calls which never return as determined from the descriptive binary data; and
creating, by the binary translator control-flow edges between the basic blocks by:
analyzing targets of direct branch instructions in the raw binary code, and
adding edges in the IR of the binary translator using the descriptive binary data for targets of indirect branch instructions;

in response to receiving the descriptive binary data further comprising aliasing information as it applies to the original IR and information including annotation/tracking of each original machine instruction that references memory, creating by the binary translator, aliasing information for memory references by combining analysis of the machine instructions in the raw binary code with original aliasing information in the descriptive binary data;
in response to a determination a memory reference on an original machine instruction being processed by the binary translator is at least one of same as, and a part of, a reference in the aliasing information of the descriptive binary based on the original IR, duplicating aliasing information in an alias graph of the descriptive binary data for a corresponding reference in the IR;
in response to a determination a memory reference consists of multiple references that are present in the aliasing information of the descriptive binary data, computing a union of aliases of all references in the aliasing information of the descriptive binary data corresponding to this single memory location; and
in response to a determination the memory reference does not have a corresponding reference in the IR, creating the aliasing information that the memory reference is aliased with all other memory references, refined later by analyzing at least one of a data area and an offset of the memory reference in the raw binary code and comparing with other references in the aliasing information of the descriptive binary data;
in response to receiving the descriptive binary data further comprising offsets of the machine instructions where temporary variables for decimal computations are killed, preventing, by the binary translator, copy propagation of values in the temporary variables for decimal computations beyond the offsets in the machine instructions where the temporary variables are killed;
eliminating, by the binary translator, computations, and stores to memory of values in a middle of the decimal computations when the temporary variables to which the values are stored are killed after the decimal computations; and,
generating, by the binary translator, a new compiled program module in a form of an optimized version of the compiled program module having strict compatibility to an original version of the compiled program module.