Currently an indirect call produces the following sequence on PCRelative mode:
extern void function( ); extern void (*ptrfunc) ( ); void g() { ptrfunc=function; } void f() { (*ptrfunc) ( ); }
Produce
paddi 3, 0, .LC0@PCREL, 1 ld 3, 0(3) std 2, 24(1) ld 12, 0(3) mtctr 12 bctrl ld 2, 24(1)
Though the caller does not use or preserve r2, it is still saved and restored across a function call.
This patch is added to remove these redundant save and restores for indirect call.
Is it worth mentioning AIX in the comment too, since the check also considers AIX?