This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Inefficient code generation with -fPIC.


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]