[llvm] [compiler-rt] [clang] [clang-repl] [ORC] Add support for out-of-process execution on ELF (PR #79936)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 29 19:14:09 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff bc7a3bd864be696217c4d11eddf16bed7646b60f 158cc5ec91bf085ec9914de26a1554606a1e3338 -- clang/test/Interpreter/out-of-process.cpp clang/include/clang/Interpreter/Interpreter.h clang/lib/Interpreter/IncrementalExecutor.cpp clang/lib/Interpreter/IncrementalExecutor.h clang/lib/Interpreter/Interpreter.cpp clang/test/Interpreter/dynamic-library.cpp clang/tools/clang-repl/ClangRepl.cpp compiler-rt/lib/orc/dlfcn_wrapper.cpp compiler-rt/lib/orc/elfnix_platform.cpp compiler-rt/lib/orc/elfnix_platform.h llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/include/clang/Interpreter/Interpreter.h b/clang/include/clang/Interpreter/Interpreter.h
index 314beb7b72d..c1e63a9cdb6 100644
--- a/clang/include/clang/Interpreter/Interpreter.h
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -107,7 +107,8 @@ public:
   static llvm::Expected<std::unique_ptr<Interpreter>>
   createWithOutOfProcessExecutor(
       std::unique_ptr<CompilerInstance> CI,
-      std::unique_ptr<llvm::orc::ExecutorProcessControl> EI, llvm::StringRef OrcRuntimePath);
+      std::unique_ptr<llvm::orc::ExecutorProcessControl> EI,
+      llvm::StringRef OrcRuntimePath);
   const ASTContext &getASTContext() const;
   ASTContext &getASTContext();
   const CompilerInstance *getCompilerInstance() const;
diff --git a/clang/lib/Interpreter/IncrementalExecutor.cpp b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 30b24caa4a5..3da8d24606c 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -66,7 +66,8 @@ IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC,
 IncrementalExecutor::IncrementalExecutor(
     llvm::orc::ThreadSafeContext &TSC, llvm::Error &Err,
     const clang::TargetInfo &TI,
-    std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC, llvm::StringRef OrcRuntimePath)
+    std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC,
+    llvm::StringRef OrcRuntimePath)
     : TSCtx(TSC) {
   using namespace llvm::orc;
   llvm::ErrorAsOutParameter EAO(&Err);
@@ -82,7 +83,8 @@ IncrementalExecutor::IncrementalExecutor(
     return llvm::Error::success();
   });
   Builder.setExecutorProcessControl(std::move(EPC));
-  Builder.setPlatformSetUp(llvm::orc::ExecutorNativePlatform(OrcRuntimePath.str()));
+  Builder.setPlatformSetUp(
+      llvm::orc::ExecutorNativePlatform(OrcRuntimePath.str()));
 
   if (auto JitOrErr = Builder.create()) {
     Jit = std::move(*JitOrErr);
diff --git a/clang/lib/Interpreter/IncrementalExecutor.h b/clang/lib/Interpreter/IncrementalExecutor.h
index a73ba903518..6d75594793e 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.h
+++ b/clang/lib/Interpreter/IncrementalExecutor.h
@@ -48,7 +48,8 @@ public:
                       const clang::TargetInfo &TI);
   IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC, llvm::Error &Err,
                       const clang::TargetInfo &TI,
-                      std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC, llvm::StringRef OrcRuntimePath);
+                      std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC,
+                      llvm::StringRef OrcRuntimePath);
   ~IncrementalExecutor();
 
   llvm::Error addModule(PartialTranslationUnit &PTU);
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index 13e6be3b54a..5953afbb17f 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -244,7 +244,7 @@ Interpreter::~Interpreter() {
           toString(std::move(Err)));
   }
 
-    if (EPC) {
+  if (EPC) {
     if (auto Err = EPC->disconnect()) {
       llvm::report_fatal_error(
           llvm::Twine("Failed to clean up EPC (IncrementalExecutor has not yet "
@@ -325,11 +325,11 @@ Interpreter::createWithCUDA(std::unique_ptr<CompilerInstance> CI,
   return Interp;
 }
 
-
 llvm::Expected<std::unique_ptr<Interpreter>>
 Interpreter::createWithOutOfProcessExecutor(
     std::unique_ptr<CompilerInstance> CI,
-    std::unique_ptr<llvm::orc::ExecutorProcessControl> EI, llvm::StringRef OrcRuntimePath) {
+    std::unique_ptr<llvm::orc::ExecutorProcessControl> EI,
+    llvm::StringRef OrcRuntimePath) {
   auto Interp = create(std::move(CI));
   if (auto E = Interp.takeError()) {
     return std::move(E);
@@ -389,8 +389,8 @@ llvm::Error Interpreter::CreateExecutor() {
   llvm::Error Err = llvm::Error::success();
   std::unique_ptr<IncrementalExecutor> Executor;
   if (EPC) {
-    Executor =
-        std::make_unique<IncrementalExecutor>(*TSCtx, Err, TI, std::move(EPC), OrcRuntimePath);
+    Executor = std::make_unique<IncrementalExecutor>(
+        *TSCtx, Err, TI, std::move(EPC), OrcRuntimePath);
   } else {
     Executor = std::make_unique<IncrementalExecutor>(*TSCtx, Err, TI);
   }
diff --git a/clang/tools/clang-repl/ClangRepl.cpp b/clang/tools/clang-repl/ClangRepl.cpp
index 1c43e7b5036..9f45910ed64 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -63,10 +63,9 @@ static llvm::cl::opt<std::string> OutOfProcessExecutorConnect(
     "oop-executor-connect",
     llvm::cl::desc("Connect to an out-of-process executor via TCP"),
     llvm::cl::cat(OOPCategory));
-static llvm::cl::opt<std::string> OrcRuntimePath(
-    "orc-runtime",
-    llvm::cl::desc("Path to the ORC runtime"),
-    llvm::cl::cat(OOPCategory));
+static llvm::cl::opt<std::string>
+    OrcRuntimePath("orc-runtime", llvm::cl::desc("Path to the ORC runtime"),
+                   llvm::cl::cat(OOPCategory));
 
 static void LLVMErrorHandler(void *UserData, const char *Message,
                              bool GenCrashDiag) {
@@ -194,13 +193,17 @@ static llvm::Error sanitizeOopArguments(const char *ArgV0) {
     OutOfProcessExecutor = OOPExecutorPath.str().str();
   }
 
-  // Out-of-process executors must run with the ORC runtime for destructor support.
-  if (OrcRuntimePath.empty() && (OutOfProcessExecutor.getNumOccurrences() || OutOfProcessExecutorConnect.getNumOccurrences())) {
+  // Out-of-process executors must run with the ORC runtime for destructor
+  // support.
+  if (OrcRuntimePath.empty() &&
+      (OutOfProcessExecutor.getNumOccurrences() ||
+       OutOfProcessExecutorConnect.getNumOccurrences())) {
     llvm::SmallString<256> OrcPath(llvm::sys::fs::getMainExecutable(
         ArgV0, reinterpret_cast<void *>(&sanitizeOopArguments)));
     llvm::sys::path::remove_filename(OrcPath); // Remove clang-repl filename.
     llvm::sys::path::remove_filename(OrcPath); // Remove ./bin directory.
-    llvm::sys::path::append(OrcPath, "lib/clang/18/lib/x86_64-unknown-linux-gnu/liborc_rt.a");
+    llvm::sys::path::append(
+        OrcPath, "lib/clang/18/lib/x86_64-unknown-linux-gnu/liborc_rt.a");
     OrcRuntimePath = OrcPath.str().str();
   }
 
diff --git a/compiler-rt/lib/orc/dlfcn_wrapper.cpp b/compiler-rt/lib/orc/dlfcn_wrapper.cpp
index a8b207d2715..b2c4857e313 100644
--- a/compiler-rt/lib/orc/dlfcn_wrapper.cpp
+++ b/compiler-rt/lib/orc/dlfcn_wrapper.cpp
@@ -53,8 +53,6 @@ __orc_rt_jit_dlupdate_wrapper(const char *ArgData, size_t ArgSize) {
       .release();
 }
 
-
-
 ORC_RT_INTERFACE orc_rt_CWrapperFunctionResult
 __orc_rt_jit_dlclose_wrapper(const char *ArgData, size_t ArgSize) {
   return WrapperFunction<int32_t(SPSExecutorAddr)>::handle(
diff --git a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
index b32d9d4c104..a3c5b589603 100644
--- a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
@@ -551,7 +551,7 @@ Error ELFNixPlatform::registerInitInfo(
       }
 
       Lock.lock();
-      // We can allow reinitialization by reinserting the handles to each 
+      // We can allow reinitialization by reinserting the handles to each
       // JITDylib into InitSeqs.
       InitSeqs.insert(std::make_pair(
           &JD,
diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
index 9bfbe951727..229fd97ecab 100644
--- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -116,8 +116,7 @@ public:
     }
 
     if (auto WrapperAddr =
-            ES.lookup(MainSearchOrder,
-                      J.mangleAndIntern(WrapperToCall))) {
+            ES.lookup(MainSearchOrder, J.mangleAndIntern(WrapperToCall))) {
       return ES.callSPSWrapper<SPSDLOpenSig>(WrapperAddr->getAddress(),
                                              DSOHandles[&JD], JD.getName(),
                                              int32_t(ORC_RT_RTLD_LAZY));

``````````

</details>


https://github.com/llvm/llvm-project/pull/79936


More information about the cfe-commits mailing list