From 83b162c3b23fbf81bb9c50bf72d35893795d5dbe Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 22 Jun 2016 20:59:17 +0000 Subject: [PATCH] [codeview] Fix the alignment padding that we add to list records Tweak the big-types.ll test case to catch this bug. We just need an enumerator name that doesn't have a length that is a multiple of 4. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273477 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/DebugInfo/CodeView/ListRecordBuilder.cpp | 10 ++++++---- test/DebugInfo/COFF/big-type.ll | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/DebugInfo/CodeView/ListRecordBuilder.cpp b/lib/DebugInfo/CodeView/ListRecordBuilder.cpp index eab5add310e..dc72f500c87 100644 --- a/lib/DebugInfo/CodeView/ListRecordBuilder.cpp +++ b/lib/DebugInfo/CodeView/ListRecordBuilder.cpp @@ -33,9 +33,10 @@ void ListRecordBuilder::writeListContinuation(const ListContinuationRecord &R) { } void ListRecordBuilder::finishSubRecord() { - // The builder starts at offset 2 in the actual CodeView buffer, so add an - // additional offset of 2 before computing the alignment. - uint32_t Remainder = (Builder.size() + 2) % 4; + // The type table inserts a 16 bit size field before each list, so factor that + // into our alignment padding. + uint32_t Remainder = + (Builder.size() + 2 * (ContinuationOffsets.size() + 1)) % 4; if (Remainder != 0) { for (int32_t PaddingBytesLeft = 4 - Remainder; PaddingBytesLeft > 0; --PaddingBytesLeft) { @@ -48,7 +49,8 @@ void ListRecordBuilder::finishSubRecord() { // back up and insert a continuation record, sliding the current subrecord // down. if (getLastContinuationSize() > 65535 - 8) { - SmallString<128> SubrecordCopy(Builder.str().slice(SubrecordStart, Builder.size())); + SmallString<128> SubrecordCopy( + Builder.str().slice(SubrecordStart, Builder.size())); Builder.truncate(SubrecordStart); // Write a placeholder continuation record. diff --git a/test/DebugInfo/COFF/big-type.ll b/test/DebugInfo/COFF/big-type.ll index 123ed716c6d..013bead7e7b 100644 --- a/test/DebugInfo/COFF/big-type.ll +++ b/test/DebugInfo/COFF/big-type.ll @@ -5759,7 +5759,7 @@ target triple = "x86_64-pc-windows-msvc19.0.23918" !5698 = !DIEnumerator(name: "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE5693", value: 5692) !5699 = !DIEnumerator(name: "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE5694", value: 5693) !5700 = !DIEnumerator(name: "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE5695", value: 5694) -!5701 = !DIEnumerator(name: "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE5696", value: 5695) +!5701 = !DIEnumerator(name: "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE5696", value: 5695) !5702 = !{!5703} !5703 = distinct !DIGlobalVariable(name: "x", linkageName: "\01?x@@3W4BigThing@@A", scope: !0, file: !1, line: 5698, type: !3, isLocal: false, isDefinition: true, variable: i32* @"\01?x@@3W4BigThing@@A") !5704 = !{i32 2, !"CodeView", i32 1} -- 2.50.1