]> granicus.if.org Git - llvm/commitdiff
[codeview] Fix the alignment padding that we add to list records
authorReid Kleckner <rnk@google.com>
Wed, 22 Jun 2016 20:59:17 +0000 (20:59 +0000)
committerReid Kleckner <rnk@google.com>
Wed, 22 Jun 2016 20:59:17 +0000 (20:59 +0000)
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
test/DebugInfo/COFF/big-type.ll

index eab5add310ea42a00616fa9d2012b0367ccc8f12..dc72f500c879f43c1d59b9011d9069b80762ac68 100644 (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.
index 123ed716c6d693757e4a81bc15e62768884bd49b..013bead7e7b8758f5a985e1567c7d87c8ad6acc2 100644 (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}