public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/28205]  New: Request an option to make -finstrument-functions not apply to inlined function calls
@ 2006-06-29 22:28 joev dot dubach at nuance dot com
  2006-07-03 18:01 ` [Bug middle-end/28205] " joev dot dubach at nuance dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: joev dot dubach at nuance dot com @ 2006-06-29 22:28 UTC (permalink / raw)
  To: gcc-bugs

While attempting to port a profiler designed to work with the Microsoft
compiler's /Gh and /GH (generate _penter and _pexit) options, I have
rediscovered a problem that was previously filed as bug #23296: "When compiling
code with gcc 4.0.0 or 4.0.1 and when specifying both the
-finstrument-functions and the -O3 options, then __cyg_profile_func_enter() is
called two or more times successively with exactly the same arguments (called
function pointer and call site pointer). This should never happen."  This was
marked INVALID with the comment: "This is not a bug, this is how it works now
in 4.0.0 and above with respect with the inliner."

However, this makes it more difficult to implement an efficient and accurate
profiler.  The inlined functions look just like regular ones, and can't be
billed to the called function, because the called function doesn't appear in
the binary, and its address wouldn't be given to __cyg_profile_func_enter even
if it were.  So the only semantics a profiler could get out of this are "a
function would have been called here if it hadn't been inlined, but we don't
know what it was in any case."  And when lots of functions are inlined, we'll
take a significant time hit (and possibly disturb pipelining and optimization)
to get this effectively useless knowledge.  The best we can do is say
"-fno-inline" to turn off inlining altogether, and accept a slower and less
accurate profiler.

I would like to have another option (or to change the semantics of the existing
option) that would cause inlined function calls to behave as if they had
__attribute((no_instrument_function)).  If this was too hard, it would also be
acceptable to make it be a little more heuristic and cause possibly-inlined
function calls to behave as if they had __attribute((no_instrument_function). 
Although I'm not familiar with the gcc codebase, I can imagine this working by
making a change in expand_function_start in gcc/function.c:
  current_function_profile
    = (profile_flag
       && ! DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (subr));
->
  current_function_profile
    = (profile_flag
       && ! DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (subr)
       && ! tree_inlinable_function_p (subr));


-- 
           Summary: Request an option to make -finstrument-functions not
                    apply to inlined function calls
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: joev dot dubach at nuance dot com


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


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

* [Bug middle-end/28205] Request an option to make -finstrument-functions not apply to inlined function calls
  2006-06-29 22:28 [Bug c++/28205] New: Request an option to make -finstrument-functions not apply to inlined function calls joev dot dubach at nuance dot com
@ 2006-07-03 18:01 ` joev dot dubach at nuance dot com
  2006-09-03  7:26 ` pinskia at gcc dot gnu dot org
  2006-10-06 12:40 ` andreas dot knuepfer at tu-dresden dot de
  2 siblings, 0 replies; 4+ messages in thread
From: joev dot dubach at nuance dot com @ 2006-07-03 18:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from joev dot dubach at nuance dot com  2006-07-03 18:01 -------
(In reply to comment #0)
> The best we can do is say
> "-fno-inline" to turn off inlining altogether, and accept a slower and less
> accurate profiler.

This is problematic as well, due to the existence of
__attribute__((always_inline)), which causes functions to be inlined efen when
-fno-inline is specified.  In particular, my code calls functions defined by
the system header emmintrin.h as always inlined.


-- 


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


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

* [Bug middle-end/28205] Request an option to make -finstrument-functions not apply to inlined function calls
  2006-06-29 22:28 [Bug c++/28205] New: Request an option to make -finstrument-functions not apply to inlined function calls joev dot dubach at nuance dot com
  2006-07-03 18:01 ` [Bug middle-end/28205] " joev dot dubach at nuance dot com
@ 2006-09-03  7:26 ` pinskia at gcc dot gnu dot org
  2006-10-06 12:40 ` andreas dot knuepfer at tu-dresden dot de
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-03  7:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-09-03 07:26 -------
Confirmed, it is a little hard as -finstrument-functions now applied before
inlining.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-09-03 07:26:30
               date|                            |


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


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

* [Bug middle-end/28205] Request an option to make -finstrument-functions not apply to inlined function calls
  2006-06-29 22:28 [Bug c++/28205] New: Request an option to make -finstrument-functions not apply to inlined function calls joev dot dubach at nuance dot com
  2006-07-03 18:01 ` [Bug middle-end/28205] " joev dot dubach at nuance dot com
  2006-09-03  7:26 ` pinskia at gcc dot gnu dot org
@ 2006-10-06 12:40 ` andreas dot knuepfer at tu-dresden dot de
  2 siblings, 0 replies; 4+ messages in thread
From: andreas dot knuepfer at tu-dresden dot de @ 2006-10-06 12:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from andreas dot knuepfer at tu-dresden dot de  2006-10-06 12:40 -------
Would it be feasible to pass a different function address for inlined
functions? In particular, it should not be the same address as the parent
function. 

I seem to recall that in previous versions (2.95.x, 3.x) of GCC
__cyg_profile_func_enter() used the call location of an inlined function as 
first argument. 
This is somewhere in the middle of the parent function, which makes sense
somehow. Any invalid address could be used as well.
In the end, the user could be aware of a function being inlined.


-- 

andreas dot knuepfer at tu-dresden dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andreas dot knuepfer at tu-
                   |                            |dresden dot de


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


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

end of thread, other threads:[~2006-10-06 12:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-29 22:28 [Bug c++/28205] New: Request an option to make -finstrument-functions not apply to inlined function calls joev dot dubach at nuance dot com
2006-07-03 18:01 ` [Bug middle-end/28205] " joev dot dubach at nuance dot com
2006-09-03  7:26 ` pinskia at gcc dot gnu dot org
2006-10-06 12:40 ` andreas dot knuepfer at tu-dresden dot de

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).