When I parsed my program, I saw that gcc used jmp for the second call to pthread_wait_barrier when compiling with -O3. Why is this so?
What advantage is achieved using jmp instead of calling . What tricks does the compiler play here? I assume that its execution of tail call optimization is here.
By the way, I am using a static link here.
__attribute__ ((noinline)) void my_pthread_barrier_wait(
volatile int tid, pthread_barrier_t *pbar )
{
pthread_barrier_wait( pbar );
if ( tid == 0 )
{
if ( !rollbacked )
{
take_checkpoint_or_rollback( ++iter == 4 );
}
}
SETJMP( tid );
asm("addr2jmp:");
pthread_barrier_wait( pbar );
dummy_var = dummy_func();
}
source
share