summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>2020-03-13 12:22:09 -0400
committerTom Stellard <tstellar@redhat.com>2020-04-16 12:05:11 -0700
commit6196695ec5819c0df7efe3fecca5c4ef9ea80b1c (patch)
treee1d5605bb16ca9b7ef3886e07ee1dbf80f7d0869 /llvm/include
parentcc6e51a1414989ff1c2dcab30c00ac10ea19afa1 (diff)
downloadbcm5719-llvm-6196695ec5819c0df7efe3fecca5c4ef9ea80b1c.tar.gz
bcm5719-llvm-6196695ec5819c0df7efe3fecca5c4ef9ea80b1c.zip
[CodeView] Align type records on 4-bytes when emitting PDBs
When emitting PDBs, the TypeStreamMerger class is used to merge .debug$T records from the input .OBJ files into the output .PDB stream. Records in .OBJs are not required to be aligned on 4-bytes, and "The Netwide Assembler 2.14" generates non-aligned records. When compiling with -DLLVM_ENABLE_ASSERTIONS=ON, an assert was triggered in MergingTypeTableBuilder when non-ghash merging was used. With ghash merging there was no assert. As a result, LLD could potentially generate a non-aligned TPI stream. We now align records on 4-bytes when record indices are remapped, in TypeStreamMerger::remapIndices(). Differential Revision: https://reviews.llvm.org/D75081 (cherry picked from commit a7325298e1f311b383b8ce5ba8e2d3698fef472a)
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h b/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
index 3b103c22770..bb8cc032e28 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h
@@ -71,6 +71,11 @@ public:
template <typename CreateFunc>
TypeIndex insertRecordAs(GloballyHashedType Hash, size_t RecordSize,
CreateFunc Create) {
+ assert(RecordSize < UINT32_MAX && "Record too big");
+ assert(RecordSize % 4 == 0 &&
+ "RecordSize is not a multiple of 4 bytes which will cause "
+ "misalignment in the output TPI stream!");
+
auto Result = HashedRecords.try_emplace(Hash, nextTypeIndex());
if (LLVM_UNLIKELY(Result.second /*inserted*/ ||
OpenPOWER on IntegriCloud