[LLVMbugs] [Bug 13202] New: Clang duplicates debug info for inlined functions
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Jun 25 07:29:45 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13202
Bug #: 13202
Summary: Clang duplicates debug info for inlined functions
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: samsonov at google.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Not sure yet if it's a clang or LLVM codegen bug.
$ cat inline-bug.cc
#include <stdio.h>
static inline int ident(int argument) {
int c = 0;
printf("%d\n", c);
return c;
}
int main() {
return ident(0);
}
$ clang++ -g -O2 inline-bug.cc -S -emit-llvm
$ grep argument inline-bug.s
!15 = metadata !{i32 786689, metadata !10, metadata !"argument", metadata !6,
i32 16777219, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ]
!18 = metadata !{i32 786689, metadata !10, metadata !"argument", metadata !6,
i32 16777219, metadata !9, i32 0, metadata !19} ; [ DW_TAG_arg_variable ]
So, there are two metadata records for arg_variable "argument", one of which is
a reference to its inline location. However, generated dwarf contains two
identical records:
$ clang++ -g -O2 inline-bug.cc -o inline-bug.out
$ readelf -wi inline-bug.out
...
<1><8c>: Abbrev Number: 8 (DW_TAG_subprogram)
<8d> DW_AT_MIPS_linkage_name: (indirect string, offset: 0x84): _ZL5identi
<91> DW_AT_name : (indirect string, offset: 0x8f): ident
<95> DW_AT_decl_file : 1
<96> DW_AT_decl_line : 3
<97> DW_AT_type : <0x85>
<9b> DW_AT_inline : 1 (inlined)
<2><9c>: Abbrev Number: 9 (DW_TAG_formal_parameter)
<9d> DW_AT_name : (indirect string, offset: 0x95): argument
<a1> DW_AT_decl_file : 1
<a2> DW_AT_decl_line : 3
<a3> DW_AT_type : <0x85>
<2><a7>: Abbrev Number: 9 (DW_TAG_formal_parameter)
<a8> DW_AT_name : (indirect string, offset: 0x95): argument
<ac> DW_AT_decl_file : 1
<ad> DW_AT_decl_line : 3
<ae> DW_AT_type : <0x85>
<2><b2>: Abbrev Number: 10 (DW_TAG_lexical_block)
...
And they are interpreted as two identical parameters by, e.g., gdb:
$ gdb inline-bug.out
(gdb) start
Temporary breakpoint 1, main () at inline-bug.cc:10
10 return ident(0);
(gdb) step
ident (argument=<optimized out>, argument=<optimized out>) at inline-bug.cc:5
5 printf("%d\n", c);
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list