https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121424
Bug ID: 121424
Summary: Debug info associates return instruction with inlined
function
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: jryans at gmail dot com
Target Milestone: ---
Created attachment 62065
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62065&action=edit
example.c
When compiling the attached program with recent GCC versions, we see that
`skip_prefix` is inlined into `cleanup_path` (as requested), but if we look at
the debug info from e.g. GCC 16 we see:
0x00000087: DW_TAG_inlined_subroutine
DW_AT_abstract_origin (0x000000d6 "skip_prefix")
DW_AT_ranges (0x0000000c
[0x0000000000000000, 0x0000000000000000)
[0x0000000000000008, 0x0000000000000020))
...which includes a `ret` instruction:
0x1f: ret
I would not expect an inlined subroutine's instruction ranges to include a
return instruction like this, as that would seem to clearly be part of the
parent out-of-line function (`cleanup_path` in this case) behaviour.
This behaviour seems to be present for quite a long ways back in GCC history...
I was able to confirm it is present at least back to the GCC 11 series, but it
may go much further back as well.
If we compare GCC to Clang here, Clang shows the expected behaviour (no returns
associated with the inlined instruction ranges).
Also available on Compiler Explorer: https://godbolt.org/z/5q1s65WPE