From: Zachary Turner Date: Fri, 10 Jun 2016 21:47:26 +0000 (+0000) Subject: [pdb] Fix issues with pdb writing. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=936d48972b26f5106011ef37cadf8e65575b5d70;p=llvm [pdb] Fix issues with pdb writing. This fixes an alignment issue by forcing all cached allocations to be 8 byte aligned, and also fixes an issue arising on big endian systems by writing ulittle32_t's instead of uint32_t's in the test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272437 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp b/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp index 86e799ca663..36f8ead090a 100644 --- a/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp +++ b/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp @@ -104,7 +104,7 @@ Error MappedBlockStream::readBytes(uint32_t Offset, uint32_t Size, // into it, and return an ArrayRef to that. Do not touch existing pool // allocations, as existing clients may be holding a pointer which must // not be invalidated. - uint8_t *WriteBuffer = Pool.Allocate(Size); + uint8_t *WriteBuffer = static_cast(Pool.Allocate(Size, 8)); if (auto EC = readBytes(Offset, MutableArrayRef(WriteBuffer, Size))) return EC; diff --git a/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp b/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp index fe55b9a3cd9..c9bc9986f45 100644 --- a/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp +++ b/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp @@ -308,6 +308,7 @@ TEST(MappedBlockStreamTest, TestWriteThenRead) { MappedBlockStreamImpl S(llvm::make_unique(0, F), F); enum class MyEnum : uint32_t { Val1 = 2908234, Val2 = 120891234 }; + using support::ulittle32_t; uint16_t u16[] = {31468, 0}; uint32_t u32[] = {890723408, 0}; @@ -315,7 +316,9 @@ TEST(MappedBlockStreamTest, TestWriteThenRead) { StringRef ZStr[] = {"Zero Str", ""}; StringRef FStr[] = {"Fixed Str", ""}; ArrayRef byteArray[] = {{'1', '2'}, {'0', '0'}}; - ArrayRef intArray[] = {{890723408, 29082234}, {0, 0}}; + ArrayRef intArray[] = { + {ulittle32_t(890723408), ulittle32_t(29082234)}, + {ulittle32_t(0), ulittle32_t(0)}}; StreamReader Reader(S); StreamWriter Writer(S);