Patent ID: 8117604

Claim:
A method for implementing architecture cloning for a program, the method comprising: receiving, at an initial analysis stage within a compiler, a program written in a platform neutral format, the program being reconfigurable to operate in a plurality of architecture targets; the initial analysis stage including: constructing in the compiler a program call graph in a beginning of a link phase of interprocedural analysis to model calling relationships between one or more procedures in the program; analyzing the program call graph via the compiler to obtain information about the program; analyzing the program to identify the one or more procedures subject to architecture cloning; using information obtained in the initial analysis stage to invoke an architecture cloning stage, the architecture cloning stage including: marking the one or more procedures in the program suitable for architecture cloning upon a determination of feasibility of architecture cloning for the one or more procedures in the program; traversing the program call graph from top-down to perform procedure cloning; naming the one or more procedures in the program suitable for architecture cloning, the cloning including re-mapping parameters of a candidate procedure according to the target architecture, and duplicating the body of the procedure; invoking architecture cloning when one or more candidate procedures are identified during procedure cloning; inserting a runtime routine call in the program at an entry point of the program, such that that the routine when executed within the compiled program will cause the compiled program to detect an architecture of a system the compiled program is being run on, the type of the detected architecture being stored in a global variable; generating with the compiler the compiled program that includes architectural specific instructions optimized for each of the multiple architecture targets, all of the architectural specific instructions for all of the multiple architecture targets being included in a single binary; providing the compiled program to the system; determining the architecture of the system based on the global variable; and selecting appropriate architectural specific instructions from the single binary to execute based on the architecture of the system.