[PATCH] D131510: [Orc] Reorder operations in ExecutorSharedMemoryMapperService shutdown

Anubhab Ghosh via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 9 10:37:24 PDT 2022


argentite created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
argentite added reviewers: RKSimon, lhames, sgraenitz.
argentite published this revision for review.
argentite added a comment.
Herald added subscribers: llvm-commits, StephenFan.
Herald added a project: LLVM.

This should fix https://reviews.llvm.org/D128544#3710127 but I think we may not even need the lock at all since this is called only at shutdown.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131510

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
@@ -265,18 +265,21 @@
 
 Error ExecutorSharedMemoryMapperService::shutdown() {
   std::vector<ExecutorAddr> ReservationAddrs;
-  if (!Reservations.empty()) {
+  {
     std::lock_guard<std::mutex> Lock(Mutex);
-    {
-      ReservationAddrs.reserve(Reservations.size());
-      for (const auto &R : Reservations) {
-        ReservationAddrs.push_back(ExecutorAddr::fromPtr(R.getFirst()));
-      }
+
+    if (Reservations.empty())
+      return Error::success();
+
+    ReservationAddrs.reserve(Reservations.size());
+    for (const auto &R : Reservations) {
+      ReservationAddrs.push_back(ExecutorAddr::fromPtr(R.getFirst()));
     }
+
+    Reservations.clear();
   }
-  return release(ReservationAddrs);
 
-  return Error::success();
+  return release(ReservationAddrs);
 }
 
 void ExecutorSharedMemoryMapperService::addBootstrapSymbols(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131510.451200.patch
Type: text/x-patch
Size: 1168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220809/d9b2fa07/attachment.bin>


More information about the llvm-commits mailing list