public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/45632]  New: const function pointer propagation issues with inlining
@ 2010-09-10  8:50 andi-gcc at firstfloor dot org
  2010-09-10  8:51 ` [Bug middle-end/45632] " andi-gcc at firstfloor dot org
  2010-09-10  9:28 ` rguenth at gcc dot gnu dot org
  0 siblings, 2 replies; 4+ messages in thread
From: andi-gcc at firstfloor dot org @ 2010-09-10  8:50 UTC (permalink / raw)
  To: gcc-bugs

The attached test case is testing inlining of const function pointers
in a typical "OO code written in C" situation.

The code shows two optimization problems:

- a_foo is inlined into main, b_foo is not.
The only difference is that new_a() returns a const pointer 
and new_b() does not. I would have assumed that gcc detects that the pointer
coming out of new_b() is const.

- p->ops->op2 is never inlined, not even for a, even though the compiler
should have enough information to do so (everything that is passed in is 
const). I assume this is because cloning does not work through
function pointers?


-- 
           Summary: const function pointer propagation issues with inlining
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andi-gcc at firstfloor dot org
  GCC host triplet: x86_64-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45632


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/45632] const function pointer propagation issues with inlining
  2010-09-10  8:50 [Bug middle-end/45632] New: const function pointer propagation issues with inlining andi-gcc at firstfloor dot org
@ 2010-09-10  8:51 ` andi-gcc at firstfloor dot org
  2010-09-10  9:28 ` rguenth at gcc dot gnu dot org
  1 sibling, 0 replies; 4+ messages in thread
From: andi-gcc at firstfloor dot org @ 2010-09-10  8:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from andi-gcc at firstfloor dot org  2010-09-10 08:50 -------
Created an attachment (id=21763)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21763&action=view)
testcase, compiled with -O3


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45632


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/45632] const function pointer propagation issues with inlining
  2010-09-10  8:50 [Bug middle-end/45632] New: const function pointer propagation issues with inlining andi-gcc at firstfloor dot org
  2010-09-10  8:51 ` [Bug middle-end/45632] " andi-gcc at firstfloor dot org
@ 2010-09-10  9:28 ` rguenth at gcc dot gnu dot org
  1 sibling, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-09-10  9:28 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org, hubicka at gcc dot gnu
                   |                            |dot org, jamborm at gcc dot
                   |                            |gnu dot org
           Severity|normal                      |enhancement
           Keywords|                            |missed-optimization


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45632


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug middle-end/45632] const function pointer propagation issues with inlining
       [not found] <bug-45632-4@http.gcc.gnu.org/bugzilla/>
@ 2011-10-21 14:08 ` jamborm at gcc dot gnu.org
  0 siblings, 0 replies; 4+ messages in thread
From: jamborm at gcc dot gnu.org @ 2011-10-21 14:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45632

--- Comment #2 from Martin Jambor <jamborm at gcc dot gnu.org> 2011-10-21 14:07:53 UTC ---
Is the second call to func() in main we pass the pointer p again, p2
being basically thrown away, I think that is a mistake because this
way, there isn't actually any call to b_foo in the testcase, just two
calls to a_foo.

BTW, currently (at -O3 and on i686) not even these calls to a_foo is
inlined.  Just one of them is direct but the other one is not, presumably
because we don't believe in the constantness of *p over the first call
at this stage.  When I change the testcase to pass p2 to the second
invocation of func, neither a_foo nor b_foo are inlined either.

So it seems to me that in order to inline both cases we'd need
aggregate return functions that we would be able to combine with
indirect cgraph edges at inlining time.  Tough.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-10-21 14:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-10  8:50 [Bug middle-end/45632] New: const function pointer propagation issues with inlining andi-gcc at firstfloor dot org
2010-09-10  8:51 ` [Bug middle-end/45632] " andi-gcc at firstfloor dot org
2010-09-10  9:28 ` rguenth at gcc dot gnu dot org
     [not found] <bug-45632-4@http.gcc.gnu.org/bugzilla/>
2011-10-21 14:08 ` jamborm at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).