[PATCH] D41734: [DebugInfo][PDB] Fix too many FPM blocks being written in some cases

Colden Cullen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 10:37:56 PST 2018


colden created this revision.
colden added a reviewer: zturner.
Herald added a subscriber: JDevlieghere.

The current interval counting math includes the two following issues:

- The Super Block (and Fpm0 when using Fpm1) are included in the block count, even though they don't have associated free page maps
- When calculating the number of existing free page maps, we should divide by block size + 1, to include the FPMs associated with the blocks

This error only occurs when the total number of blocks present is within 1 (up or down) of a multiple of 4096, so it's pretty rare. Mine was hitting right at 12289.

I'm 90% sure this is the correct fix for this, but if anyone can point out a better place I'm happy to poke around some more.


Repository:
  rL LLVM

https://reviews.llvm.org/D41734

Files:
  include/llvm/DebugInfo/MSF/MSFCommon.h


Index: include/llvm/DebugInfo/MSF/MSFCommon.h
===================================================================
--- include/llvm/DebugInfo/MSF/MSFCommon.h
+++ include/llvm/DebugInfo/MSF/MSFCommon.h
@@ -110,12 +110,15 @@
 
 inline uint32_t getNumFpmIntervals(const MSFLayout &L,
                                    bool IncludeUnusedFpmData = false) {
+  // Need to subtract the free block map index from the number of blocks
+  // so the blocks before Fpm (SB & Fpm0 if using Fpm1) aren't included
+  // Need to add 1 to block size so the interval includes the already present FPM blocks
   if (IncludeUnusedFpmData)
-    return divideCeil(L.SB->NumBlocks, L.SB->BlockSize);
+    return divideCeil(L.SB->NumBlocks - L.SB->FreeBlockMapBlock, L.SB->BlockSize + 1);
 
   // We want the minimum number of intervals required, where each interval can
   // represent BlockSize * 8 blocks.
-  return divideCeil(L.SB->NumBlocks, 8 * L.SB->BlockSize);
+  return divideCeil(L.SB->NumBlocks - L.SB->FreeBlockMapBlock, 8 * L.SB->BlockSize);
 }
 
 Error validateSuperBlock(const SuperBlock &SB);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41734.128577.patch
Type: text/x-patch
Size: 1102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180104/13c59942/attachment.bin>


More information about the llvm-commits mailing list