[PATCH] D58538: [DebugInfo] Add source attributes for function declaration on behalf of owner CU
Eugene Leviant via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 21 23:59:47 PST 2019
evgeny777 created this revision.
evgeny777 added reviewers: pcc, dblaikie, dexonsmith, chandlerc.
Herald added subscribers: jdoerfert, aprantl, mehdi_amini.
There seems to be a bug in DwarfUnit which one can easily step on when building boost examples with full LTO.
It causes template function declaration inside a class to have invalid `DW_AT_decl_file` attribute and GNU
objdump and addr2line tools to report multiple failures while processing such executables.
Assume we have following C++ structure:
struct S {
int foo;
template< class T > T squared(T value) { return value * value; }
};
Even though this structure contains two elements, debug information for it will contain only one,
because `squared` may not be used anywhere in the program and so may not even be compiled.
!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, ....)
!18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "S", ...., elements !19, ....)
!19 = !{!20}
!20 = !DIDerivedType(tag: DW_TAG_member, name: "foo", ....)
If some CU in a program is using S::squared two records will be added to debug information: definition and declaration
The latter will reference `struct S` via `scope field`:
!37 = distinct !DISubprogram(name: "squared<int>", unit !2, declaration !38, .....)
!38 = distinct !DISubprogram(name: "squared<int>", scope !18, ....)
The `struct S` could be used in multiple CUs, some of them may use `squared` and some may not. When full LTO is used
IRMover will combine debug information from all CUs merging the types and DIE corresponding to declaration of `squared`
my be processed by DwarfUnit instance corresponding to CU#1 and DIE corresponding to its scope (struct S) may be owned
by CU#2. In such case if we add source line attributes for declaration on behalf of CU#1 we'll likely break the debug info,
because file ids in CU#1 and CU#2 don't match.
This patch fixes the issue by adding debug info for declaration on behalf of owning CU.
https://reviews.llvm.org/D58538
Files:
include/llvm/CodeGen/DIE.h
lib/CodeGen/AsmPrinter/DIE.cpp
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
test/DebugInfo/X86/template_function_decl.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58538.187906.patch
Type: text/x-patch
Size: 9009 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190222/2d67de99/attachment.bin>
More information about the llvm-commits
mailing list