[PATCH] D132313: [Orc] Memory Mapper fixes

Anubhab Ghosh via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 21 02:29:55 PDT 2022


argentite updated this revision to Diff 454286.
argentite added a comment.

Properly rebase everything


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132313/new/

https://reviews.llvm.org/D132313

Files:
  llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp


Index: llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
+++ llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
@@ -198,6 +198,17 @@
         AllErr = joinErrors(std::move(AllErr), std::move(Err));
       }
 
+      // Remove the allocation from the allocation list of its reservation
+      for (auto &Reservation : Reservations) {
+        auto AllocationIt =
+            std::find(Reservation.second.Allocations.begin(),
+                      Reservation.second.Allocations.end(), Base);
+        if (AllocationIt != Reservation.second.Allocations.end()) {
+          Reservation.second.Allocations.erase(AllocationIt);
+          break;
+        }
+      }
+
       Allocations.erase(Base);
     }
   }
@@ -264,22 +275,15 @@
 }
 
 Error ExecutorSharedMemoryMapperService::shutdown() {
-  std::vector<ExecutorAddr> ReservationAddrs;
-  {
-    std::lock_guard<std::mutex> Lock(Mutex);
+  if (Reservations.empty())
+    return Error::success();
 
-    if (Reservations.empty())
-      return Error::success();
-
-    ReservationAddrs.reserve(Reservations.size());
-    for (const auto &R : Reservations) {
-      ReservationAddrs.push_back(ExecutorAddr::fromPtr(R.getFirst()));
-    }
-
-    Reservations.clear();
-  }
+  std::vector<ExecutorAddr> ReservationAddrs;
+  ReservationAddrs.reserve(Reservations.size());
+  for (const auto &R : Reservations)
+    ReservationAddrs.push_back(ExecutorAddr::fromPtr(R.getFirst()));
 
-  return release(ReservationAddrs);
+  return release(std::move(ReservationAddrs));
 }
 
 void ExecutorSharedMemoryMapperService::addBootstrapSymbols(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132313.454286.patch
Type: text/x-patch
Size: 1795 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220821/998b4e37/attachment.bin>


More information about the llvm-commits mailing list