When comparing performance of shared libraries one need to use -fno-semantic-interposition to get apples-to-apples comparsions between GCC and LLVM since LLVM ignored ELF interposition rules.
Compiling the following with -O2 -fpic:
int ret1()
{
return 1;
}
int test()
{
return ret1();
}
LLVM will optimize test to:
which assumes that one never interposes ret1 with different implementation. GCC keeps the call:
and only optimizes it with -O2 -fpic -fno-semantic-interposition. This can make a lot of performance difference.
Compiling the following with -O2 -fpic:
int ret1()
{
return 1;
}
int test()
{
return ret1();
}
LLVM will optimize test to:
test:
movl $1, %eax
retq
movl $1, %eax
retq
test:
xorl %eax, %eax
jmp ret1@PLT
xorl %eax, %eax
jmp ret1@PLT
Comment