This is the mail archive of the
mailing list for the GCC project.
Re: what is function cloning?
ranjith kumar <firstname.lastname@example.org> 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.