[llvm-commits] Trampoline changes

Chris Lattner clattner at apple.com
Fri Sep 28 14:43:58 PDT 2007


On Sep 28, 2007, at 2:38 PM, Duncan Sands wrote:

> Hi Chris,
>
>>> Also
>>> 5. Within foo, you need to check that nothing too complicated is
>>> done to P1, for example it isn't stored in a global or passed to
>>> some other function.
>>
>> Actually, worse case, you could just make a trampoline in foo.
>> However, you're right that this is only worth doing if there are
>> calls to the fn pointer in foo.  OTOH, propagating the trampoline
>> creation site down to foo will allow it to be further propagated into
>> functions that foo might call.
>
> that could be very costly.  Initializing a trampoline is not very
> costly.  What is costly is using it and then modifying the stack
> contents where the trampoline was, because you get an icache flush.
> Eg: if you push the trampoline down into a function called in a loop,
> then you risk calling the trampoline then dirtying that part of the
> stack (after function return, due to other local variables using that
> part of the stack) and thus taking a large hit on every iteration.

Fair enough. :)

-Chris



More information about the llvm-commits mailing list