[MSF] Fix FPM interval calcluation
We have some code to try to determine how many pieces an MSF
Free Page Map is split into, and this code had an off by one
error which would cause the calculation to be incorrect when
there were exactly 4096*k + 1 blocks in an MSF file.
Original investigation and patch outline by Colden Cullen.
Differential Revision: https://reviews.llvm.org/D41742
llvm-svn: 321880
diff --git a/llvm/lib/DebugInfo/MSF/MSFCommon.cpp b/llvm/lib/DebugInfo/MSF/MSFCommon.cpp
index d7e1dcf..d398304 100644
--- a/llvm/lib/DebugInfo/MSF/MSFCommon.cpp
+++ b/llvm/lib/DebugInfo/MSF/MSFCommon.cpp
@@ -64,15 +64,13 @@
bool IncludeUnusedFpmData,
bool AltFpm) {
MSFStreamLayout FL;
- uint32_t NumFpmIntervals = getNumFpmIntervals(Msf, IncludeUnusedFpmData);
- support::ulittle32_t FpmBlock = Msf.SB->FreeBlockMapBlock;
- assert(FpmBlock == 1 || FpmBlock == 2);
- if (AltFpm) {
- // If they requested the alternate FPM, then 2 becomes 1 and 1 becomes 2.
- FpmBlock = 3U - FpmBlock;
- }
+ uint32_t NumFpmIntervals =
+ getNumFpmIntervals(Msf, IncludeUnusedFpmData, AltFpm);
+
+ uint32_t FpmBlock = AltFpm ? Msf.alternateFpmBlock() : Msf.mainFpmBlock();
+
for (uint32_t I = 0; I < NumFpmIntervals; ++I) {
- FL.Blocks.push_back(FpmBlock);
+ FL.Blocks.push_back(support::ulittle32_t(FpmBlock));
FpmBlock += msf::getFpmIntervalLength(Msf);
}