mirror of https://github.com/microsoft/clang.git
![]() Summary: The change "[CodeView] Implement support for bit fields in Clang" (r274201, https://reviews.llvm.org/rL274201) broke the calculation of bit offsets for the debug info describing bitfields on big-endian targets. Prior to commit r274201 the debug info for bitfields got their offsets from the ASTRecordLayout in CGDebugInfo::CollectRecordFields(), the current field offset was then passed on to CGDebugInfo::CollectRecordNormalField() and used directly in the DIDerivedType. Since commit r274201, the bit offset ending up in the DIDerivedType no longer comes directly from the ASTRecordLayout. Instead CGDebugInfo::CollectRecordNormalField() calls the new method CGDebugInfo::createBitFieldType(), which in turn calls CodeGenTypes::getCGRecordLayout().getBitFieldInfo() to fetch a CGBitFieldInfo describing the field. The 'Offset' member of CGBitFieldInfo is then used to calculate the bit offset of the DIDerivedType. Unfortunately the previous and current method of calculating the bit offset are only equivalent for little endian targets, as CGRecordLowering::setBitFieldInfo() reverses the bit offsets for big endian targets as the last thing it does. A simple reproducer for this error is the following module: struct fields { unsigned a : 4; unsigned b : 4; } flags = {0x0f, 0x1}; Compiled for Mips, with commit r274200 both the DIDerivedType bit offsets on the IR-level and the DWARF information on the ELF-level will have the expected values: the offsets of 'a' and 'b' are 0 and 4 respectively. With r274201 the offsets are switched to 4 and 0. By noting that the static initialization of 'flags' in both cases is the same, we can eliminate a change in record layout as the cause of the change in the debug info. Also compiling this example with gcc, produces the same record layout and debug info as commit r274200. In order to restore the previous function we extend CGDebugInfo::createBitFieldType() to compensate for the reversal done in CGRecordLowering::setBitFieldInfo(). Patch by Frej Drejhammar! Reviewers: cfe-commits, majnemer, rnk, aaboud, echristo, aprantl Reviewed By: rnk, aprantl Subscribers: aprantl, arichardson, frej Differential Revision: https://reviews.llvm.org/D32745 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305224 91177308-0d34-0410-b5e6-96231b3b80d8 |
||
---|---|---|
INPUTS | ||
bindings | ||
cmake | ||
docs | ||
examples | ||
include | ||
lib | ||
runtime | ||
test | ||
tools | ||
unittests | ||
utils | ||
www | ||
.arcconfig | ||
.clang-format | ||
.clang-tidy | ||
.gitignore | ||
CMakeLists.txt | ||
CODE_OWNERS.TXT | ||
INSTALL.txt | ||
LICENSE.TXT | ||
ModuleInfo.txt | ||
NOTES.txt | ||
README.txt |
README.txt
//===----------------------------------------------------------------------===// // C Language Family Front-end //===----------------------------------------------------------------------===// Welcome to Clang. This is a compiler front-end for the C family of languages (C, C++, Objective-C, and Objective-C++) which is built as part of the LLVM compiler infrastructure project. Unlike many other compiler frontends, Clang is useful for a number of things beyond just compiling code: we intend for Clang to be host to a number of different source-level tools. One example of this is the Clang Static Analyzer. If you're interested in more (including how to build Clang) it is best to read the relevant web sites. Here are some pointers: Information on Clang: http://clang.llvm.org/ Building and using Clang: http://clang.llvm.org/get_started.html Clang Static Analyzer: http://clang-analyzer.llvm.org/ Information on the LLVM project: http://llvm.org/ If you have questions or comments about Clang, a great place to discuss them is on the Clang development mailing list: http://lists.llvm.org/mailman/listinfo/cfe-dev If you find a bug in Clang, please file it in the LLVM bug tracker: http://llvm.org/bugs/