Bug 26364 - [4.2 regression] [no unit-at-a-time mode] Uninlined function is marked as inlined
Summary: [4.2 regression] [no unit-at-a-time mode] Uninlined function is marked as inl...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-19 20:10 UTC by H.J. Lu
Modified: 2009-03-30 15:49 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work: 3.4.6 4.3.0
Known to fail: 4.1.0 4.2.0 4.0.0 4.2.5
Last reconfirmed: 2008-01-09 10:38:03


Attachments
A testcase (75.64 KB, application/octet-stream)
2006-02-19 20:15 UTC, H.J. Lu
Details
small testcase (78 bytes, text/plain)
2006-02-22 00:43 UTC, Jim Wilson
Details
Reject combination of -fno-unit-at-a-time and -finline-functions-called-once (449 bytes, patch)
2008-01-08 12:53 UTC, Steven Bosscher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2006-02-19 20:10:51 UTC
Gcc 4.1/4.2 generates wrong DWARF info when it fails to inline a static function.
Comment 1 Andrew Pinski 2006-02-19 20:13:50 UTC
Testcase????
Comment 2 H.J. Lu 2006-02-19 20:15:00 UTC
Created attachment 10877 [details]
A testcase

This is the preprocess Linux kernel code for gcc 4.1 and 4.2. There are many
static functions, like pageout, have DWARF2 info like:

<1><9aee>: Abbrev Number: 78 (DW_TAG_subprogram)
     DW_AT_sibling     : <9bd1>
     DW_AT_name        : (indirect string, offset: 0x44b6): pageout
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 318
     DW_AT_prototyped  : 1
     DW_AT_type        : <8df5>
     DW_AT_inline      : 1      (inlined)

where pageout isn't inlined at all. Gcc 3.4.6 generates:

 <1><8eb1>: Abbrev Number: 84 (DW_TAG_subprogram)
     DW_AT_sibling     : <8fe0>
     DW_AT_name        : (indirect string, offset: 0x4182): pageout
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 295
     DW_AT_prototyped  : 1
     DW_AT_type        : <84b0>
     DW_AT_low_pc      : 0x318
     DW_AT_high_pc     : 0x3e4
     DW_AT_frame_base  : 1 byte block: 54       (DW_OP_reg4)
Comment 3 Andrew Pinski 2006-02-19 20:18:53 UTC
Next time don't attach a tar ball, please.
Comment 4 Jim Wilson 2006-02-22 00:28:36 UTC
The debug info looks OK to me, though it is more verbose than it needs to be.

I think you may be reading the debug info wrong.  The entry you are looking at is the abstract origin for pageout.  If you take the offset of this entry, 9aee in your case, and search for that, you will find the real debug info for pageout, which has an abstract origin attribute pointing at the 9aee entry.  I get slightly different addresses, but here is what I get
        .uleb128 0x4e   # (DIE (0x9af3) DW_TAG_subprogram)
        .long   0x9bd6  # DW_AT_sibling
        .long   .LASF1677       # DW_AT_name: "pageout"
        .byte   0x1     # DW_AT_decl_file
        .value  0x13e   # DW_AT_decl_line
        .byte   0x1     # DW_AT_prototyped
        .long   0x8df5  # DW_AT_type
        .byte   0x1     # DW_AT_inline
        ...
        .uleb128 0x3e   # (DIE (0x9bd6) DW_TAG_subprogram)
        .long   0x9d39  # DW_AT_sibling
        .long   0x9af3  # DW_AT_abstract_origin
        .long   .LFB813 # DW_AT_low_pc
        .long   .LFE813 # DW_AT_high_pc
        .long   .LLST34 # DW_AT_frame_base
So the debug info is correct, in the sense it correctly describes the program.

The debug is more verbose than it should be though, since there is no need for the abstract origin if the function was never inlined.  This is due to problems with cgraph.  Now that cgraph controls when and how we emit code for functions, we really need to move the debug output calls into cgraph, so that functions are finalized by cgraph before we try to emit debug info for them.  There are a few other bugzilla bug reports concerning the same issue, though it may not be easy to find them.  It is probably also not easy to fix this.

See cgraph_function_possibly_inlined_p.

What is the real bug that you are trying to report here?  Are you complaining because the debug info is unnecessarily verbose?  Do you have a debugger that doesn't handle this debug info correctly?
Comment 5 Jim Wilson 2006-02-22 00:39:48 UTC
I should mention that your testcase uses -Os, and -Os enables -finline-functions-called-once.  This is why the function is marked as "inline".  If you don't want this feature, you can turn it off.

Also, -fno-unit-at-a-time is expected to disappear at some point, so problems that only appear with this option may not be worth fixing if they are too hard to fix.  

Using both -finline-functions-called-once and -fno-unit-at-a-time is contradictory, so it isn't surprising there is a problem.  We could try to detect that and turn one of them off, possibly with a warning.
Comment 6 Jim Wilson 2006-02-22 00:43:48 UTC
Created attachment 10888 [details]
small testcase

Compile this with 
     ./xgcc -B./ -Os -fno-unit-at-a-time -g -dA -S tmp.c -fverbose-asm
and notice that we have an abstract_origin die for sub, even though it was never inlined.  Also notice the -finline* options listed at the top of the .s file.  These are enabled by -Os.
Comment 7 Mark Mitchell 2006-02-23 23:46:27 UTC
This problem concerns quasi-invalid debug information in an obscure compilation mode; P2.
Comment 8 Mark Mitchell 2006-02-24 00:27:03 UTC
This issue will not be resolved in GCC 4.1.0; retargeted at GCC 4.1.1.
Comment 9 Mark Mitchell 2006-05-25 02:34:03 UTC
Will not be fixed in 4.1.1; adjust target milestone to 4.1.2.
Comment 10 Steven Bosscher 2007-12-16 23:24:59 UTC
Could this be fixed by rejecting -finline-functions-called-once if -fno-unit-at-a-time is given?  A patch to do this should be quite trivial.
Comment 11 Steven Bosscher 2008-01-08 12:53:22 UTC
Created attachment 14899 [details]
Reject combination of -fno-unit-at-a-time and -finline-functions-called-once

Untested, but shows how easy it should be to "fix" this bug by disallowing this strange combination of flags.
Comment 12 Richard Biener 2008-01-09 10:34:39 UTC
Subject: Bug 26364

Author: rguenth
Date: Wed Jan  9 10:33:55 2008
New Revision: 131423

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131423
Log:
2008-01-09  Steven Bosscher  <stevenb.gcc@gmail.com>

	PR debug/26364
	* opts.c (decode_options): Disable inlining of functions called
	once if not in unit-at-a-time mode.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/opts.c

Comment 13 Richard Biener 2008-01-09 10:38:03 UTC
Fixed on the trunk.
Comment 14 Joseph S. Myers 2008-07-04 20:21:20 UTC
Closing 4.1 branch.
Comment 15 Joseph S. Myers 2009-03-30 15:49:26 UTC
Closing 4.2 branch, fixed in 4.3.