[compiler-rt] [llvm] [Orc][Runtime] Refactor `dlupdate` to remove the `mode` argument (PR #110491)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 04:09:54 PDT 2024
https://github.com/SahilPatidar created https://github.com/llvm/llvm-project/pull/110491
None
>From 6db7575a64f8f50ca18842dc8a34ed9050c5d61b Mon Sep 17 00:00:00 2001
From: SahilPatidar <patidarsahil2001 at gmail.com>
Date: Mon, 30 Sep 2024 12:09:18 +0530
Subject: [PATCH] [Orc][Runtime] Refactor `dlupdate` to remove the `mode`
argument
---
compiler-rt/lib/orc/dlfcn_wrapper.cpp | 8 ++++----
compiler-rt/lib/orc/macho_platform.cpp | 14 +++++++-------
compiler-rt/lib/orc/macho_platform.h | 2 +-
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp | 5 ++---
4 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/compiler-rt/lib/orc/dlfcn_wrapper.cpp b/compiler-rt/lib/orc/dlfcn_wrapper.cpp
index bbbc79f607f270..dec8d1e5bbc31e 100644
--- a/compiler-rt/lib/orc/dlfcn_wrapper.cpp
+++ b/compiler-rt/lib/orc/dlfcn_wrapper.cpp
@@ -20,7 +20,7 @@ using namespace orc_rt;
extern "C" const char *__orc_rt_jit_dlerror();
extern "C" void *__orc_rt_jit_dlopen(const char *path, int mode);
-extern "C" int __orc_rt_jit_dlupdate(void *dso_handle, int mode);
+extern "C" int __orc_rt_jit_dlupdate(void *dso_handle);
extern "C" int __orc_rt_jit_dlclose(void *dso_handle);
ORC_RT_INTERFACE orc_rt_CWrapperFunctionResult
@@ -45,10 +45,10 @@ __orc_rt_jit_dlopen_wrapper(const char *ArgData, size_t ArgSize) {
#ifdef __APPLE__
ORC_RT_INTERFACE orc_rt_CWrapperFunctionResult
__orc_rt_jit_dlupdate_wrapper(const char *ArgData, size_t ArgSize) {
- return WrapperFunction<int32_t(SPSExecutorAddr, int32_t)>::handle(
+ return WrapperFunction<int32_t(SPSExecutorAddr)>::handle(
ArgData, ArgSize,
- [](ExecutorAddr &DSOHandle, int32_t mode) {
- return __orc_rt_jit_dlupdate(DSOHandle.toPtr<void *>(), mode);
+ [](ExecutorAddr &DSOHandle) {
+ return __orc_rt_jit_dlupdate(DSOHandle.toPtr<void *>());
})
.release();
}
diff --git a/compiler-rt/lib/orc/macho_platform.cpp b/compiler-rt/lib/orc/macho_platform.cpp
index a65e5b94eb4f40..f0e7d04fa9c146 100644
--- a/compiler-rt/lib/orc/macho_platform.cpp
+++ b/compiler-rt/lib/orc/macho_platform.cpp
@@ -245,7 +245,7 @@ class MachOPlatformRuntimeState {
const char *dlerror();
void *dlopen(std::string_view Name, int Mode);
- int dlupdate(void *DSOHandle, int Mode);
+ int dlupdate(void *DSOHandle);
int dlclose(void *DSOHandle);
void *dlsym(void *DSOHandle, const char *Symbol);
@@ -295,7 +295,7 @@ class MachOPlatformRuntimeState {
Error dlopenInitialize(std::unique_lock<std::mutex> &JDStatesLock,
JITDylibState &JDS, MachOJITDylibDepInfoMap &DepInfo);
- Error dlupdateImpl(void *DSOHandle, int Mode);
+ Error dlupdateImpl(void *DSOHandle);
Error dlupdateFull(std::unique_lock<std::mutex> &JDStatesLock,
JITDylibState &JDS);
Error dlupdateInitialize(std::unique_lock<std::mutex> &JDStatesLock,
@@ -710,13 +710,13 @@ void *MachOPlatformRuntimeState::dlopen(std::string_view Path, int Mode) {
}
}
-int MachOPlatformRuntimeState::dlupdate(void *DSOHandle, int Mode) {
+int MachOPlatformRuntimeState::dlupdate(void *DSOHandle) {
ORC_RT_DEBUG({
std::string S;
printdbg("MachOPlatform::dlupdate(%p) (%s)\n", DSOHandle, S.c_str());
});
std::lock_guard<std::recursive_mutex> Lock(DyldAPIMutex);
- if (auto Err = dlupdateImpl(DSOHandle, Mode)) {
+ if (auto Err = dlupdateImpl(DSOHandle)) {
// FIXME: Make dlerror thread safe.
DLFcnError = toString(std::move(Err));
return -1;
@@ -1179,7 +1179,7 @@ Error MachOPlatformRuntimeState::dlopenInitialize(
return Error::success();
}
-Error MachOPlatformRuntimeState::dlupdateImpl(void *DSOHandle, int Mode) {
+Error MachOPlatformRuntimeState::dlupdateImpl(void *DSOHandle) {
std::unique_lock<std::mutex> Lock(JDStatesMutex);
// Try to find JITDylib state by DSOHandle.
@@ -1513,8 +1513,8 @@ void *__orc_rt_macho_jit_dlopen(const char *path, int mode) {
return MachOPlatformRuntimeState::get().dlopen(path, mode);
}
-int __orc_rt_macho_jit_dlupdate(void *dso_handle, int mode) {
- return MachOPlatformRuntimeState::get().dlupdate(dso_handle, mode);
+int __orc_rt_macho_jit_dlupdate(void *dso_handle) {
+ return MachOPlatformRuntimeState::get().dlupdate(dso_handle);
}
int __orc_rt_macho_jit_dlclose(void *dso_handle) {
diff --git a/compiler-rt/lib/orc/macho_platform.h b/compiler-rt/lib/orc/macho_platform.h
index ad70c97809d2f6..aeab248f7f8ae4 100644
--- a/compiler-rt/lib/orc/macho_platform.h
+++ b/compiler-rt/lib/orc/macho_platform.h
@@ -24,7 +24,7 @@ ORC_RT_INTERFACE void __orc_rt_macho_cxa_finalize(void *dso_handle);
// dlfcn functions.
ORC_RT_INTERFACE const char *__orc_rt_macho_jit_dlerror();
ORC_RT_INTERFACE void *__orc_rt_macho_jit_dlopen(const char *path, int mode);
-ORC_RT_INTERFACE int __orc_rt_macho_jit_dlupdate(void *dso_handle, int mode);
+ORC_RT_INTERFACE int __orc_rt_macho_jit_dlupdate(void *dso_handle);
ORC_RT_INTERFACE int __orc_rt_macho_jit_dlclose(void *dso_handle);
ORC_RT_INTERFACE void *__orc_rt_macho_jit_dlsym(void *dso_handle,
const char *symbol);
diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
index 19b3f3d6ea0380..22bc8288b754ad 100644
--- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -602,7 +602,7 @@ Error ORCPlatformSupport::initialize(orc::JITDylib &JD) {
using llvm::orc::shared::SPSExecutorAddr;
using llvm::orc::shared::SPSString;
using SPSDLOpenSig = SPSExecutorAddr(SPSString, int32_t);
- using SPSDLUpdateSig = int32_t(SPSExecutorAddr, int32_t);
+ using SPSDLUpdateSig = int32_t(SPSExecutorAddr);
enum dlopen_mode : int32_t {
ORC_RT_RTLD_LAZY = 0x1,
ORC_RT_RTLD_NOW = 0x2,
@@ -628,8 +628,7 @@ Error ORCPlatformSupport::initialize(orc::JITDylib &JD) {
if (dlupdate) {
int32_t result;
auto E = ES.callSPSWrapper<SPSDLUpdateSig>(WrapperAddr->getAddress(),
- result, DSOHandles[&JD],
- int32_t(ORC_RT_RTLD_LAZY));
+ result, DSOHandles[&JD]);
if (E)
return E;
else if (result)
More information about the llvm-commits
mailing list