Inefficient code generation with -fPIC.

suckfish@ihug.co.nz suckfish@ihug.co.nz
Sun Nov 12 12:58:00 GMT 2000


Dear All,

I've got a problem with with -fPIC on i386 generating inefficient code.

However, I haven't been able to reproduce the problem with a short test
case, so I'm writing to ask if it would be worth while for me to spend
further time to produce a decent bug-report for this [Or if I'm horribly
misunderstanding something].

The problem is that with some leaf functions (i.e., no non-inlined calls to
other functions), G++ (both 2.95.2 and recent snapshots) generates a
redundant call at the start of the function:

	call	.LPR0
	addl	$_GLOBAL_OFFSET_TABLE_, %ebx

For the particular functions in question, this appears to be dead code; all
calls to other functions are inlined, and there are no references to global
variables (%ebx is not referenced again in the code, and the strings
"@GOT" and "@PLT" do not appear).

For simpler functions compiled with -fPIC, the "call .LPR0" is indeed
optimised away.

The compiler flags I'm using are "-fPIC -g -O2 -fomit-frame-pointer
-march=i686 -ffast-math -mpreferred-stack-boundary=3".

Ralph.


More information about the Gcc mailing list