LTO and partial evaluation are completely orthogonal

from each other. One is an optimization technique

and the other is a time that optimization can

occur. Please explain a bit more about what you are

trying to accomplish.

A contrived example I had in mind is a program that

computes a power function. In pseudocode:

int powerFunc( int x, int n )

{

if n is 0

return 1

if n is even

return square( powerFunc( x, 0.5*n ) )

if n is odd

return x * powerFunc( x, n - 1 )

}

If we know what the exponent (say n = 5) is at compile

time, program can be optimized via specialization

(partial evaluation) to get:

int powerFunc5( int x )

{

return x * square( square( x ) );

}

My question is whether LLVM framework can perform

these

types of transformations at runtime so that the

function can be optimized at runtime based on the

program's input as opposed to at compile time via

specialization. If yes, what are the trade-offs?

In a real program, functions would of course be very

complex with tens of arguments.

Marko