[llvm] 0aaa74f - [Orc] Reorder operations in ExecutorSharedMemoryMapperService shutdown
    Anubhab Ghosh via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Aug 11 07:05:27 PDT 2022
    
    
  
Author: Anubhab Ghosh
Date: 2022-08-11T19:34:10+05:30
New Revision: 0aaa74f7e6e52f56631d697436383398f0a54eae
URL: https://github.com/llvm/llvm-project/commit/0aaa74f7e6e52f56631d697436383398f0a54eae
DIFF: https://github.com/llvm/llvm-project/commit/0aaa74f7e6e52f56631d697436383398f0a54eae.diff
LOG: [Orc] Reorder operations in ExecutorSharedMemoryMapperService shutdown
Differential Revision: https://reviews.llvm.org/D131510
Added: 
    
Modified: 
    llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
Removed: 
    
################################################################################
diff  --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
index caa191cea899d..fd487e3451bb0 100644
--- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
@@ -265,18 +265,21 @@ Error ExecutorSharedMemoryMapperService::release(
 
 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(
        
    
    
More information about the llvm-commits
mailing list