Revert 99881, it brooke smooshlab's llvm-gcc-i386-darwin9.
[oota-llvm.git] / lib / Support / Allocator.cpp
index 230c421f1fe17bc681e0dbdfe3b891cbaeac46ba..31b45c8d4aae77538940f8f1b9e948f7f2726e23 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Support/Allocator.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/System/DataTypes.h"
 #include "llvm/Support/Recycler.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/System/Memory.h"
 #include <cstring>
 
 namespace llvm {
@@ -60,6 +61,7 @@ void BumpPtrAllocator::DeallocateSlabs(MemSlab *Slab) {
 #ifndef NDEBUG
     // Poison the memory so stale pointers crash sooner.  Note we must
     // preserve the Size and NextPtr fields at the beginning.
+    sys::Memory::setRangeWritable(Slab + 1, Slab->Size - sizeof(MemSlab));
     memset(Slab + 1, 0xCD, Slab->Size - sizeof(MemSlab));
 #endif
     Allocator.Deallocate(Slab);
@@ -95,8 +97,8 @@ void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) {
   }
 
   // If Size is really big, allocate a separate slab for it.
-  if (Size > SizeThreshold) {
-    size_t PaddedSize = Size + sizeof(MemSlab) + Alignment - 1;
+  size_t PaddedSize = Size + sizeof(MemSlab) + Alignment - 1;
+  if (PaddedSize > SizeThreshold) {
     MemSlab *NewSlab = Allocator.Allocate(PaddedSize);
 
     // Put the new slab after the current slab, since we are not allocating