Debug info for imported declarations sometimes reference empty DIEs · Issue #51501 · llvm/llvm-project (original) (raw)
Bugzilla Link | 52159 |
---|---|
Version | 12.0 |
OS | All |
CC | @dwblaikie,@JDevlieghere,@walkerkd,@pogo59 |
Extended Description
When an imported declaration references a function that has been inlined and removed, its DIE will reference an empty subprogram DIE.
In clang, it creates a new empty DIE rather than using the existing abstract origin DIE.
$ cat main.cpp
namespace ns {
inline __attribute__((always_inline))
void foo() { int a = 4; }
}
void goo() {
using ns::foo;
foo();
}
$ clang -g main.cpp -c -o - | llvm-dwarfdump -
0x0000000b: DW_TAG_compile_unit
...
0x0000002a: DW_TAG_namespace
DW_AT_name ("ns")
0x0000002f: DW_TAG_subprogram
DW_AT_linkage_name ("_ZN2ns3fooEv")
DW_AT_name ("foo")
DW_AT_decl_line (3)
DW_AT_external (true)
DW_AT_inline (DW_INL_inlined)
0x0000003b: DW_TAG_variable
DW_AT_name ("a")
DW_AT_decl_line (3)
DW_AT_type (0x00000049 "int")
0x00000046: NULL
0x00000047: DW_TAG_subprogram
0x00000048: NULL
0x00000050: DW_TAG_subprogram
DW_AT_low_pc (0x0000000000000000)
DW_AT_high_pc (0x000000000000000d)
DW_AT_frame_base (DW_OP_reg6 RBP)
DW_AT_linkage_name ("_Z3goov")
DW_AT_name ("goo")
DW_AT_decl_line (6)
DW_AT_external (true)
0x00000069: DW_TAG_imported_declaration
DW_AT_decl_line (7)
DW_AT_import (0x00000047)
0x00000070: DW_TAG_inlined_subroutine
DW_AT_abstract_origin (0x0000002f "_ZN2ns3fooEv")
DW_AT_low_pc (0x0000000000000004)
DW_AT_high_pc (0x000000000000000b)
DW_AT_call_line (8)
DW_AT_call_column (0x03)
0x00000084: DW_TAG_variable
DW_AT_location (DW_OP_fbreg -4)
DW_AT_abstract_origin (0x0000003b "a")
0x0000008c: NULL
0x0000008d: NULL
0x0000008e: NULL