Index: lldb/trunk/source/Expression/IRMemoryMap.cpp
===================================================================
--- lldb/trunk/source/Expression/IRMemoryMap.cpp
+++ lldb/trunk/source/Expression/IRMemoryMap.cpp
@@ -53,6 +53,8 @@
     lldb::ProcessSP process_sp = m_process_wp.lock();
 
     lldb::addr_t ret = LLDB_INVALID_ADDRESS;
+    if (size == 0)
+        return ret;
 
     if (process_sp && process_sp->CanJIT() && process_sp->IsAlive())
     {
@@ -66,37 +68,13 @@
             return ret;
     }
 
-    for (int iterations = 0; iterations < 16; ++iterations)
+    ret = 0;
+    if (!m_allocations.empty())
     {
-        lldb::addr_t candidate = LLDB_INVALID_ADDRESS;
-
-        switch (target_sp->GetArchitecture().GetAddressByteSize())
-        {
-        case 4:
-            {
-                uint32_t random_data = rand();
-                candidate = random_data;
-                candidate &= ~0xfffull;
-                break;
-            }
-        case 8:
-            {
-                uint32_t random_low = rand();
-                uint32_t random_high = rand();
-                candidate = random_high;
-                candidate <<= 32ull;
-                candidate |= random_low;
-                candidate &= ~0xfffull;
-                break;
-            }
-        }
-
-        if (IntersectsAllocation(candidate, size))
-            continue;
-
-        ret = candidate;
-
-        return ret;
+        auto back = m_allocations.rbegin();
+        lldb::addr_t addr = back->first;
+        size_t alloc_size = back->second.m_size;
+        ret = llvm::RoundUpToAlignment(addr+alloc_size, 4096);
     }
 
     return ret;