what is function cloning?

Ian Lance Taylor iant@google.com
Fri Oct 23 00:43:00 GMT 2009


ranjith kumar <ranjithproxy@gmail.com> writes:

> What is function cloning?

In the context of a compiler, it's when the compiler makes a second
copy of a function with some modification.  For example, if the
compiler discovers that a function is called many different times with
the same initial parameter, it may clone the function to produce a
version which takes one less parameter, and then change all the
callers to call the clone.

Another example is that a compiler may make several clones of a
function and compile them tuned for different microarchitectures, and
then arrange for the appropriate one to be used at runtime based on
some sort of CPU test.

Ian



More information about the Gcc-help mailing list