[llvm] r273477 - [codeview] Fix the alignment padding that we add to list records

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 22 13:59:17 PDT 2016


Author: rnk
Date: Wed Jun 22 15:59:17 2016
New Revision: 273477

URL: http://llvm.org/viewvc/llvm-project?rev=273477&view=rev
Log:
[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.

Modified:
    llvm/trunk/lib/DebugInfo/CodeView/ListRecordBuilder.cpp
    llvm/trunk/test/DebugInfo/COFF/big-type.ll

Modified: llvm/trunk/lib/DebugInfo/CodeView/ListRecordBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ListRecordBuilder.cpp?rev=273477&r1=273476&r2=273477&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/ListRecordBuilder.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/ListRecordBuilder.cpp Wed Jun 22 15:59:17 2016
@@ -33,9 +33,10 @@ void ListRecordBuilder::writeListContinu
 }
 
 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.

Modified: llvm/trunk/test/DebugInfo/COFF/big-type.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/big-type.ll?rev=273477&r1=273476&r2=273477&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/big-type.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/big-type.ll Wed Jun 22 15:59:17 2016
@@ -5759,7 +5759,7 @@ target triple = "x86_64-pc-windows-msvc1
 !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}




More information about the llvm-commits mailing list