From: Anubhab Ghosh Date: Sat, 20 Aug 2022 20:13:20 +0000 (+0530) Subject: [Orc] Provide correct Reservation address for slab allocations X-Git-Tag: upstream/17.0.6~35877 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ecfee0b9eafd75627f37e2c460818bf41b39996;p=platform%2Fupstream%2Fllvm.git [Orc] Provide correct Reservation address for slab allocations When slab allocator is used, the MappingBase is not necessarily the same as the original reservation base as the allocation could be a part of the whole reservation. In this case the original reservation address needs to be passed to ExecutorSharedMemoryMapperService to associate the new allocation with the original reservation. Differential Revision: https://reviews.llvm.org/D132313 --- diff --git a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp index 734b5f0..773e6d2 100644 --- a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp +++ b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp @@ -11,6 +11,8 @@ #include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h" #include "llvm/Support/WindowsError.h" +#include + #if defined(LLVM_ON_UNIX) && !defined(__ANDROID__) #include #include @@ -300,8 +302,10 @@ char *SharedMemoryMapper::prepare(ExecutorAddr Addr, size_t ContentSize) { void SharedMemoryMapper::initialize(MemoryMapper::AllocInfo &AI, OnInitializedFunction OnInitialized) { - auto Reservation = Reservations.find(AI.MappingBase); - assert(Reservation != Reservations.end() && + auto Reservation = std::lower_bound( + Reservations.rbegin(), Reservations.rend(), AI.MappingBase, + [](const auto &A, const auto &B) { return A.first > B; }); + assert(Reservation != Reservations.rend() && "Attempt to initialize unreserved range"); tpctypes::SharedMemoryFinalizeRequest FR; @@ -336,7 +340,7 @@ void SharedMemoryMapper::initialize(MemoryMapper::AllocInfo &AI, OnInitialized(std::move(Result)); }, - SAs.Instance, AI.MappingBase, std::move(FR)); + SAs.Instance, Reservation->first, std::move(FR)); } void SharedMemoryMapper::deinitialize( @@ -418,7 +422,6 @@ SharedMemoryMapper::~SharedMemoryMapper() { UnmapViewOfFile(R.second.LocalAddr); #endif - } }