This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Inefficient code generation with -fPIC.
- To: gcc at gcc dot gnu dot org
- Subject: Inefficient code generation with -fPIC.
- From: suckfish at ihug dot co dot nz
- Date: Mon, 13 Nov 2000 09:57:56 +1300 (NZDT)
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.