[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.

llvm-svn: 273477
This commit is contained in:
Reid Kleckner 2016-06-22 20:59:17 +00:00
parent 3c0f63c98b
commit ac460619d2
2 changed files with 7 additions and 5 deletions

View File

@ -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.

View File

@ -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}