Revert "[ORC-RT] Replace FnTag arg of WrapperFunction::call with generic dispatch arg."
This reverts commit462251b80b. This reverts commit9b67c99dc5. Build fails for compiler-rt/lib/orc/tests/unit/wrapper_function_utils_test.cpp https://buildkite.com/llvm-project/upstream-bazel/builds/109731#0191da59-6710-4420-92ef-aa6e0355cb2c
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
|
||||
#include "debug.h"
|
||||
#include "error.h"
|
||||
#include "jit_dispatch.h"
|
||||
#include "wrapper_function_utils.h"
|
||||
|
||||
#include <array>
|
||||
@@ -316,9 +315,9 @@ Error COFFPlatformRuntimeState::dlopenFull(JITDylibState &JDS) {
|
||||
// Call back to the JIT to push the initializers.
|
||||
Expected<COFFJITDylibDepInfoMap> DepInfoMap((COFFJITDylibDepInfoMap()));
|
||||
if (auto Err = WrapperFunction<SPSExpected<SPSCOFFJITDylibDepInfoMap>(
|
||||
SPSExecutorAddr)>::
|
||||
call(JITDispatch(&__orc_rt_coff_push_initializers_tag), DepInfoMap,
|
||||
ExecutorAddr::fromPtr(JDS.Header)))
|
||||
SPSExecutorAddr)>::call(&__orc_rt_coff_push_initializers_tag,
|
||||
DepInfoMap,
|
||||
ExecutorAddr::fromPtr(JDS.Header)))
|
||||
return Err;
|
||||
if (!DepInfoMap)
|
||||
return DepInfoMap.takeError();
|
||||
@@ -446,9 +445,10 @@ COFFPlatformRuntimeState::lookupSymbolInJITDylib(void *header,
|
||||
std::string_view Sym) {
|
||||
Expected<ExecutorAddr> Result((ExecutorAddr()));
|
||||
if (auto Err = WrapperFunction<SPSExpected<SPSExecutorAddr>(
|
||||
SPSExecutorAddr,
|
||||
SPSString)>::call(JITDispatch(&__orc_rt_coff_symbol_lookup_tag),
|
||||
Result, ExecutorAddr::fromPtr(header), Sym))
|
||||
SPSExecutorAddr, SPSString)>::call(&__orc_rt_coff_symbol_lookup_tag,
|
||||
Result,
|
||||
ExecutorAddr::fromPtr(header),
|
||||
Sym))
|
||||
return std::move(Err);
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "common.h"
|
||||
#include "compiler.h"
|
||||
#include "error.h"
|
||||
#include "jit_dispatch.h"
|
||||
#include "wrapper_function_utils.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -353,9 +352,10 @@ ELFNixPlatformRuntimeState::lookupSymbolInJITDylib(void *DSOHandle,
|
||||
std::string_view Sym) {
|
||||
Expected<ExecutorAddr> Result((ExecutorAddr()));
|
||||
if (auto Err = WrapperFunction<SPSExpected<SPSExecutorAddr>(
|
||||
SPSExecutorAddr,
|
||||
SPSString)>::call(JITDispatch(&__orc_rt_elfnix_symbol_lookup_tag),
|
||||
Result, ExecutorAddr::fromPtr(DSOHandle), Sym))
|
||||
SPSExecutorAddr, SPSString)>::call(&__orc_rt_elfnix_symbol_lookup_tag,
|
||||
Result,
|
||||
ExecutorAddr::fromPtr(DSOHandle),
|
||||
Sym))
|
||||
return std::move(Err);
|
||||
return Result;
|
||||
}
|
||||
@@ -368,9 +368,8 @@ ELFNixPlatformRuntimeState::getJITDylibInitializersByName(
|
||||
std::string PathStr(Path.data(), Path.size());
|
||||
if (auto Err =
|
||||
WrapperFunction<SPSExpected<SPSELFNixJITDylibInitializerSequence>(
|
||||
SPSString)>::
|
||||
call(JITDispatch(&__orc_rt_elfnix_get_initializers_tag), Result,
|
||||
Path))
|
||||
SPSString)>::call(&__orc_rt_elfnix_get_initializers_tag, Result,
|
||||
Path))
|
||||
return std::move(Err);
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
//===------ jit_dispatch.h - Call back to an ORC controller -----*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file is a part of the ORC runtime support library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef ORC_RT_JIT_DISPATCH_H
|
||||
#define ORC_RT_JIT_DISPATCH_H
|
||||
|
||||
#include "common.h"
|
||||
#include "wrapper_function_utils.h"
|
||||
|
||||
namespace orc_rt {
|
||||
|
||||
class JITDispatch {
|
||||
public:
|
||||
JITDispatch(const void *FnTag) : FnTag(FnTag) {}
|
||||
|
||||
WrapperFunctionResult operator()(const char *ArgData, size_t ArgSize) {
|
||||
// Since the functions cannot be zero/unresolved on Windows, the following
|
||||
// reference taking would always be non-zero, thus generating a compiler
|
||||
// warning otherwise.
|
||||
#if !defined(_WIN32)
|
||||
if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch_ctx))
|
||||
return WrapperFunctionResult::createOutOfBandError(
|
||||
"__orc_rt_jit_dispatch_ctx not set")
|
||||
.release();
|
||||
if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch))
|
||||
return WrapperFunctionResult::createOutOfBandError(
|
||||
"__orc_rt_jit_dispatch not set")
|
||||
.release();
|
||||
#endif
|
||||
|
||||
return __orc_rt_jit_dispatch(&__orc_rt_jit_dispatch_ctx, FnTag, ArgData,
|
||||
ArgSize);
|
||||
}
|
||||
|
||||
private:
|
||||
const void *FnTag;
|
||||
};
|
||||
|
||||
} // namespace orc_rt
|
||||
|
||||
#endif // ORC_RT_JIT_DISPATCH_H
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "debug.h"
|
||||
#include "error.h"
|
||||
#include "interval_map.h"
|
||||
#include "jit_dispatch.h"
|
||||
#include "wrapper_function_utils.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -916,7 +915,7 @@ Error MachOPlatformRuntimeState::requestPushSymbols(
|
||||
Error OpErr = Error::success();
|
||||
if (auto Err = WrapperFunction<SPSError(
|
||||
SPSExecutorAddr, SPSSequence<SPSTuple<SPSString, bool>>)>::
|
||||
call(JITDispatch(&__orc_rt_macho_push_symbols_tag), OpErr,
|
||||
call(&__orc_rt_macho_push_symbols_tag, OpErr,
|
||||
ExecutorAddr::fromPtr(JDS.Header), Symbols)) {
|
||||
cantFail(std::move(OpErr));
|
||||
return std::move(Err);
|
||||
@@ -1146,9 +1145,8 @@ Error MachOPlatformRuntimeState::dlopenFull(
|
||||
// Unlock so that we can accept the initializer update.
|
||||
JDStatesLock.unlock();
|
||||
if (auto Err = WrapperFunction<SPSExpected<SPSMachOJITDylibDepInfoMap>(
|
||||
SPSExecutorAddr)>::
|
||||
call(JITDispatch(&__orc_rt_macho_push_initializers_tag), DepInfo,
|
||||
ExecutorAddr::fromPtr(JDS.Header)))
|
||||
SPSExecutorAddr)>::call(&__orc_rt_macho_push_initializers_tag,
|
||||
DepInfo, ExecutorAddr::fromPtr(JDS.Header)))
|
||||
return Err;
|
||||
JDStatesLock.lock();
|
||||
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
#ifndef ORC_RT_WRAPPER_FUNCTION_UTILS_H
|
||||
#define ORC_RT_WRAPPER_FUNCTION_UTILS_H
|
||||
|
||||
#include "orc_rt/c_api.h"
|
||||
#include "common.h"
|
||||
#include "error.h"
|
||||
#include "executor_address.h"
|
||||
#include "orc_rt/c_api.h"
|
||||
#include "simple_packed_serialization.h"
|
||||
#include <type_traits>
|
||||
|
||||
@@ -287,22 +288,30 @@ private:
|
||||
using ResultSerializer = detail::ResultSerializer<SPSRetTagT, RetT>;
|
||||
|
||||
public:
|
||||
template <typename DispatchFn, typename RetT, typename... ArgTs>
|
||||
static Error call(DispatchFn &&Dispatch, RetT &Result, const ArgTs &...Args) {
|
||||
template <typename RetT, typename... ArgTs>
|
||||
static Error call(const void *FnTag, RetT &Result, const ArgTs &...Args) {
|
||||
|
||||
// RetT might be an Error or Expected value. Set the checked flag now:
|
||||
// we don't want the user to have to check the unused result if this
|
||||
// operation fails.
|
||||
detail::ResultDeserializer<SPSRetTagT, RetT>::makeSafe(Result);
|
||||
|
||||
// Since the functions cannot be zero/unresolved on Windows, the following
|
||||
// reference taking would always be non-zero, thus generating a compiler
|
||||
// warning otherwise.
|
||||
#if !defined(_WIN32)
|
||||
if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch_ctx))
|
||||
return make_error<StringError>("__orc_rt_jit_dispatch_ctx not set");
|
||||
if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch))
|
||||
return make_error<StringError>("__orc_rt_jit_dispatch not set");
|
||||
#endif
|
||||
auto ArgBuffer =
|
||||
WrapperFunctionResult::fromSPSArgs<SPSArgList<SPSTagTs...>>(Args...);
|
||||
if (const char *ErrMsg = ArgBuffer.getOutOfBandError())
|
||||
return make_error<StringError>(ErrMsg);
|
||||
|
||||
WrapperFunctionResult ResultBuffer =
|
||||
Dispatch(ArgBuffer.data(), ArgBuffer.size());
|
||||
|
||||
WrapperFunctionResult ResultBuffer = __orc_rt_jit_dispatch(
|
||||
&__orc_rt_jit_dispatch_ctx, FnTag, ArgBuffer.data(), ArgBuffer.size());
|
||||
if (auto ErrMsg = ResultBuffer.getOutOfBandError())
|
||||
return make_error<StringError>(ErrMsg);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user