[llvm-commits] [llvm] r50374 - /llvm/branches/Apple/Tak/lib/Support/Allocator.cpp

Dan Gohman gohman at apple.com
Mon Apr 28 14:36:28 PDT 2008


Author: djg
Date: Mon Apr 28 16:36:28 2008
New Revision: 50374

URL: http://llvm.org/viewvc/llvm-project?rev=50374&view=rev
Log:
Porting r50362 and r50372 to Tak.

Modified:
    llvm/branches/Apple/Tak/lib/Support/Allocator.cpp

Modified: llvm/branches/Apple/Tak/lib/Support/Allocator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Tak/lib/Support/Allocator.cpp?rev=50374&r1=50373&r2=50374&view=diff

==============================================================================
--- llvm/branches/Apple/Tak/lib/Support/Allocator.cpp (original)
+++ llvm/branches/Apple/Tak/lib/Support/Allocator.cpp Mon Apr 28 16:36:28 2008
@@ -46,13 +46,16 @@
   /// Allocate - Allocate and return at least the specified number of bytes.
   ///
   void *Allocate(unsigned AllocSize, unsigned Alignment, MemRegion **RegPtr) {
-    // Round size up to an even multiple of the alignment.
-    AllocSize = (AllocSize+Alignment-1) & ~(Alignment-1);
     
-    // If there is space in this region, return it.
-    if (unsigned(NextPtr+AllocSize-(char*)this) <= RegionSize) {
-      void *Result = NextPtr;
-      NextPtr += AllocSize;
+    char* Result = (char*) (((uintptr_t) (NextPtr+Alignment-1)) 
+                            & ~((uintptr_t) Alignment-1));
+
+    // Speculate the new value of NextPtr.
+    char* NextPtrTmp = Result + AllocSize;
+    
+    // If we are still within the current region, return Result.
+    if (unsigned (NextPtrTmp - (char*) this) <= RegionSize) {
+      NextPtr = NextPtrTmp;
       return Result;
     }
     





More information about the llvm-commits mailing list