From de6a487d7027c8f0d9df74b806a3bc777b4f6f77 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 5 Jan 2018 18:12:14 +0000 Subject: [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 --- llvm/lib/DebugInfo/MSF/MSFCommon.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'llvm/lib/DebugInfo/MSF/MSFCommon.cpp') diff --git a/llvm/lib/DebugInfo/MSF/MSFCommon.cpp b/llvm/lib/DebugInfo/MSF/MSFCommon.cpp index d7e1dcf31a3..d398304375a 100644 --- a/llvm/lib/DebugInfo/MSF/MSFCommon.cpp +++ b/llvm/lib/DebugInfo/MSF/MSFCommon.cpp @@ -64,15 +64,13 @@ MSFStreamLayout llvm::msf::getFpmStreamLayout(const MSFLayout &Msf, 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); } -- cgit v1.2.3