[llvm] r197401 - MemoryBuffer: Increase the alignment of small file buffers to 16
Reid Kleckner
reid at kleckner.net
Mon Dec 16 10:18:12 PST 2013
Author: rnk
Date: Mon Dec 16 12:18:12 2013
New Revision: 197401
URL: http://llvm.org/viewvc/llvm-project?rev=197401&view=rev
Log:
MemoryBuffer: Increase the alignment of small file buffers to 16
This was manifesting as an LLVM_ASSUME_ALIGNED() failure in an ELF debug
info test when building LLVM with clang in the Microsoft C++ ABI.
Modified:
llvm/trunk/lib/Support/MemoryBuffer.cpp
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=197401&r1=197400&r2=197401&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Mon Dec 16 12:18:12 2013
@@ -131,9 +131,10 @@ MemoryBuffer *MemoryBuffer::getNewUninit
StringRef BufferName) {
// Allocate space for the MemoryBuffer, the data and the name. It is important
// that MemoryBuffer and data are aligned so PointerIntPair works with them.
+ // TODO: Is 16-byte alignment enough? We copy small object files with large
+ // alignment expectations into this buffer.
size_t AlignedStringLen =
- RoundUpToAlignment(sizeof(MemoryBufferMem) + BufferName.size() + 1,
- sizeof(void*)); // TODO: Is sizeof(void*) enough?
+ RoundUpToAlignment(sizeof(MemoryBufferMem) + BufferName.size() + 1, 16);
size_t RealLen = AlignedStringLen + Size + 1;
char *Mem = static_cast<char*>(operator new(RealLen, std::nothrow));
if (!Mem) return 0;
More information about the llvm-commits
mailing list