OSDN Git Service

[GlobalOpt] Include padding in debug fragments
authorMikael Holmen <mikael.holmen@ericsson.com>
Fri, 2 Feb 2018 10:34:13 +0000 (10:34 +0000)
committerMikael Holmen <mikael.holmen@ericsson.com>
Fri, 2 Feb 2018 10:34:13 +0000 (10:34 +0000)
commit299f8c346e1ab483463da5f02536ffd00b7ad9c6
treea07145944722d067b3e17e62c705b90542055031
parent87885d427aafd0410ac0e518b55b59092b40a332
[GlobalOpt] Include padding in debug fragments

Summary:
When creating the debug fragments for a SRA'd variable, use the types'
allocation sizes. This fixes issues where the pass would emit too small
fragments, placed at the wrong offset, for padded types.

An example of this is long double on x86. The type is represented using
x86_fp80, which is 10 bytes, but the value is aligned to 12/16 bytes.
The padding is included in the type's DW_AT_byte_size attribute;
therefore, the fragments should also include that. Newer GCC releases
(I tested 7.2.0) emit 12/16-byte pieces for long double. Earlier
releases, e.g. GCC 5.5.0, behaved as LLVM did, i.e. by emitting a
10-byte piece, followed by an empty 2/6-byte piece for the padding.

Failing to cover all `DW_AT_byte_size' bytes of a value with non-empty
pieces results in the value being printed as <optimized out> by GDB.

Patch by: David Stenberg

Reviewers: aprantl, JDevlieghere

Reviewed By: aprantl, JDevlieghere

Subscribers: llvm-commits

Tags: #debug-info

Differential Revision: https://reviews.llvm.org/D42807

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@324066 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/IPO/GlobalOpt.cpp
test/DebugInfo/X86/global-sra-fp80-array.ll [new file with mode: 0644]
test/DebugInfo/X86/global-sra-fp80-struct.ll [new file with mode: 0644]