Bug 7515 - invalid inlining
Summary: invalid inlining
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 2.96
: P3 normal
Target Milestone: ---
Assignee: Richard Henderson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-08-06 20:26 UTC by Ulrich Drepper
Modified: 2003-07-25 17:33 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
o3.c (60 bytes, application/octet-stream)
2003-05-21 15:17 UTC, Ulrich Drepper
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Drepper 2002-08-06 20:26:00 UTC
When -O3 is used gcc performs invalid inlining optimizations.  Functions, which are not declared static or have a visibility != default must not be inlined.  At least when generating code for ELF binaries.  The semantic changes since 'foo' will not be looked up using the ELF symbol resolution rules which would allow interposition.

Release:
at least 2.96 and later

Environment:
x86 Linux, but probably all others

How-To-Repeat:
Compile the attached code with -O3.  The result is that 'foo' gets inlined.
Comment 1 Ulrich Drepper 2002-08-06 20:26:00 UTC
Fix:
Only inline if the function is static, has visibility != default, or possibly if a new function attribute or command line option is used.
Comment 2 Geoff Keating 2002-08-06 21:10:33 UTC
Responsible-Changed-From-To: unassigned->geoffk
Responsible-Changed-Why: Working on fix.
Comment 3 Geoff Keating 2002-08-06 21:10:33 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Reproduced with GCC 3.1 and -O3 -fpic.
Comment 4 Geoff Keating 2002-08-06 21:11:41 UTC
From: Geoff Keating <geoffk@geoffk.org>
To: drepper@redhat.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: optimization/7515: invalid inlining
Date: 06 Aug 2002 21:11:41 -0700

 This is not a bug unless -fpic is used, since executables themselves
 will not have any symbols overriden, correct?
 -- 
 - Geoffrey Keating <geoffk@geoffk.org> <geoffk@redhat.com>

Comment 5 Ulrich Drepper 2002-08-06 21:17:05 UTC
From: Ulrich Drepper <drepper@redhat.com>
To: Geoff Keating <geoffk@geoffk.org>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: optimization/7515: invalid inlining
Date: Tue, 06 Aug 2002 21:17:05 -0700

 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 Geoff Keating wrote:
 > This is not a bug unless -fpic is used, since executables themselves
 > will not have any symbols overriden, correct?
 
 This assumes clueful programmers.  Often code for DSO are compiled 
 without -fpic.  Sometimes it gets forgotten.  Other times people believe 
 the "PIC register prevents optimization" myth.  The text relocations 
 DSOs and up with having often go completely unnoticed.
 
 So, no, -fpic is no prerequisite for this being a bug.
 
 - -- 
 - ---------------.                          ,-.   1325 Chesapeake Terrace
 Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
 Red Hat          `--' drepper at redhat.com   `------------------------
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
 iD8DBQE9UJ9H2ijCOnn/RHQRAiJwAKCgut+4fC4Zoq3VUC2a/knlBz/pRACggv8B
 gg0/a/wOdwawFNE4IOxUseg=
 =Mdrw
 -----END PGP SIGNATURE-----
 
Comment 6 Richard Henderson 2002-08-30 19:43:04 UTC
Responsible-Changed-From-To: geoffk->rth
Responsible-Changed-Why: .
Comment 7 Richard Henderson 2002-08-30 19:43:04 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: http://gcc.gnu.org/ml/gcc-patches/2002-08/msg01829.html
    http://gcc.gnu.org/ml/gcc-patches/2002-08/msg01830.html