[llvm] a1fc260 - [JITLink] Add a synchronous version of finalize for convenience.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 10:15:22 PDT 2020


Author: Lang Hames
Date: 2020-07-13T10:15:10-07:00
New Revision: a1fc26030a42e9639e678344a4c08014a8cbba3d

URL: https://github.com/llvm/llvm-project/commit/a1fc26030a42e9639e678344a4c08014a8cbba3d
DIFF: https://github.com/llvm/llvm-project/commit/a1fc26030a42e9639e678344a4c08014a8cbba3d.diff

LOG: [JITLink] Add a synchronous version of finalize for convenience.

This will be used by upcoming patches that implement indirection utils
(reentry, reentry trampolines, and stubs) on top of
JITLinkMemoryManager to unify in-process and cross-process lazy
compilation support.

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
index ac5a593bb77b..3bb56f4d9615 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
@@ -17,7 +17,9 @@
 #include "llvm/ExecutionEngine/JITSymbol.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Memory.h"
+
 #include <cstdint>
+#include <future>
 
 namespace llvm {
 namespace jitlink {
@@ -74,6 +76,15 @@ class JITLinkMemoryManager {
     /// working memory.
     virtual void finalizeAsync(FinalizeContinuation OnFinalize) = 0;
 
+    /// Calls finalizeAsync and waits for completion.
+    Error finalize() {
+      std::promise<Error> FinalizeResultP;
+      auto FinalizeResultF = FinalizeResultP.get_future();
+      finalizeAsync(
+          [&](Error Err) { FinalizeResultP.set_value(std::move(Err)); });
+      return FinalizeResultF.get();
+    }
+
     /// Should deallocate target memory.
     virtual Error deallocate() = 0;
   };


        


More information about the llvm-commits mailing list