Skip to content

Commit 53d35c4

Browse files
committed
Revert "[ORC-RT] Replace FnTag arg of WrapperFunction::call with generic dispatch arg."
This reverts commit 462251b. This reverts commit 9b67c99. 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
1 parent 831236e commit 53d35c4

File tree

5 files changed

+31
-75
lines changed

5 files changed

+31
-75
lines changed

compiler-rt/lib/orc/coff_platform.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "debug.h"
1919
#include "error.h"
20-
#include "jit_dispatch.h"
2120
#include "wrapper_function_utils.h"
2221

2322
#include <array>
@@ -316,9 +315,9 @@ Error COFFPlatformRuntimeState::dlopenFull(JITDylibState &JDS) {
316315
// Call back to the JIT to push the initializers.
317316
Expected<COFFJITDylibDepInfoMap> DepInfoMap((COFFJITDylibDepInfoMap()));
318317
if (auto Err = WrapperFunction<SPSExpected<SPSCOFFJITDylibDepInfoMap>(
319-
SPSExecutorAddr)>::
320-
call(JITDispatch(&__orc_rt_coff_push_initializers_tag), DepInfoMap,
321-
ExecutorAddr::fromPtr(JDS.Header)))
318+
SPSExecutorAddr)>::call(&__orc_rt_coff_push_initializers_tag,
319+
DepInfoMap,
320+
ExecutorAddr::fromPtr(JDS.Header)))
322321
return Err;
323322
if (!DepInfoMap)
324323
return DepInfoMap.takeError();
@@ -446,9 +445,10 @@ COFFPlatformRuntimeState::lookupSymbolInJITDylib(void *header,
446445
std::string_view Sym) {
447446
Expected<ExecutorAddr> Result((ExecutorAddr()));
448447
if (auto Err = WrapperFunction<SPSExpected<SPSExecutorAddr>(
449-
SPSExecutorAddr,
450-
SPSString)>::call(JITDispatch(&__orc_rt_coff_symbol_lookup_tag),
451-
Result, ExecutorAddr::fromPtr(header), Sym))
448+
SPSExecutorAddr, SPSString)>::call(&__orc_rt_coff_symbol_lookup_tag,
449+
Result,
450+
ExecutorAddr::fromPtr(header),
451+
Sym))
452452
return std::move(Err);
453453
return Result;
454454
}

compiler-rt/lib/orc/elfnix_platform.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "common.h"
1515
#include "compiler.h"
1616
#include "error.h"
17-
#include "jit_dispatch.h"
1817
#include "wrapper_function_utils.h"
1918

2019
#include <algorithm>
@@ -353,9 +352,10 @@ ELFNixPlatformRuntimeState::lookupSymbolInJITDylib(void *DSOHandle,
353352
std::string_view Sym) {
354353
Expected<ExecutorAddr> Result((ExecutorAddr()));
355354
if (auto Err = WrapperFunction<SPSExpected<SPSExecutorAddr>(
356-
SPSExecutorAddr,
357-
SPSString)>::call(JITDispatch(&__orc_rt_elfnix_symbol_lookup_tag),
358-
Result, ExecutorAddr::fromPtr(DSOHandle), Sym))
355+
SPSExecutorAddr, SPSString)>::call(&__orc_rt_elfnix_symbol_lookup_tag,
356+
Result,
357+
ExecutorAddr::fromPtr(DSOHandle),
358+
Sym))
359359
return std::move(Err);
360360
return Result;
361361
}
@@ -368,9 +368,8 @@ ELFNixPlatformRuntimeState::getJITDylibInitializersByName(
368368
std::string PathStr(Path.data(), Path.size());
369369
if (auto Err =
370370
WrapperFunction<SPSExpected<SPSELFNixJITDylibInitializerSequence>(
371-
SPSString)>::
372-
call(JITDispatch(&__orc_rt_elfnix_get_initializers_tag), Result,
373-
Path))
371+
SPSString)>::call(&__orc_rt_elfnix_get_initializers_tag, Result,
372+
Path))
374373
return std::move(Err);
375374
return Result;
376375
}

compiler-rt/lib/orc/jit_dispatch.h

Lines changed: 0 additions & 50 deletions
This file was deleted.

compiler-rt/lib/orc/macho_platform.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "debug.h"
1717
#include "error.h"
1818
#include "interval_map.h"
19-
#include "jit_dispatch.h"
2019
#include "wrapper_function_utils.h"
2120

2221
#include <algorithm>
@@ -916,7 +915,7 @@ Error MachOPlatformRuntimeState::requestPushSymbols(
916915
Error OpErr = Error::success();
917916
if (auto Err = WrapperFunction<SPSError(
918917
SPSExecutorAddr, SPSSequence<SPSTuple<SPSString, bool>>)>::
919-
call(JITDispatch(&__orc_rt_macho_push_symbols_tag), OpErr,
918+
call(&__orc_rt_macho_push_symbols_tag, OpErr,
920919
ExecutorAddr::fromPtr(JDS.Header), Symbols)) {
921920
cantFail(std::move(OpErr));
922921
return std::move(Err);
@@ -1146,9 +1145,8 @@ Error MachOPlatformRuntimeState::dlopenFull(
11461145
// Unlock so that we can accept the initializer update.
11471146
JDStatesLock.unlock();
11481147
if (auto Err = WrapperFunction<SPSExpected<SPSMachOJITDylibDepInfoMap>(
1149-
SPSExecutorAddr)>::
1150-
call(JITDispatch(&__orc_rt_macho_push_initializers_tag), DepInfo,
1151-
ExecutorAddr::fromPtr(JDS.Header)))
1148+
SPSExecutorAddr)>::call(&__orc_rt_macho_push_initializers_tag,
1149+
DepInfo, ExecutorAddr::fromPtr(JDS.Header)))
11521150
return Err;
11531151
JDStatesLock.lock();
11541152

compiler-rt/lib/orc/wrapper_function_utils.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
#ifndef ORC_RT_WRAPPER_FUNCTION_UTILS_H
1414
#define ORC_RT_WRAPPER_FUNCTION_UTILS_H
1515

16+
#include "orc_rt/c_api.h"
17+
#include "common.h"
1618
#include "error.h"
1719
#include "executor_address.h"
18-
#include "orc_rt/c_api.h"
1920
#include "simple_packed_serialization.h"
2021
#include <type_traits>
2122

@@ -287,22 +288,30 @@ class WrapperFunction<SPSRetTagT(SPSTagTs...)> {
287288
using ResultSerializer = detail::ResultSerializer<SPSRetTagT, RetT>;
288289

289290
public:
290-
template <typename DispatchFn, typename RetT, typename... ArgTs>
291-
static Error call(DispatchFn &&Dispatch, RetT &Result, const ArgTs &...Args) {
291+
template <typename RetT, typename... ArgTs>
292+
static Error call(const void *FnTag, RetT &Result, const ArgTs &...Args) {
292293

293294
// RetT might be an Error or Expected value. Set the checked flag now:
294295
// we don't want the user to have to check the unused result if this
295296
// operation fails.
296297
detail::ResultDeserializer<SPSRetTagT, RetT>::makeSafe(Result);
297298

299+
// Since the functions cannot be zero/unresolved on Windows, the following
300+
// reference taking would always be non-zero, thus generating a compiler
301+
// warning otherwise.
302+
#if !defined(_WIN32)
303+
if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch_ctx))
304+
return make_error<StringError>("__orc_rt_jit_dispatch_ctx not set");
305+
if (ORC_RT_UNLIKELY(!&__orc_rt_jit_dispatch))
306+
return make_error<StringError>("__orc_rt_jit_dispatch not set");
307+
#endif
298308
auto ArgBuffer =
299309
WrapperFunctionResult::fromSPSArgs<SPSArgList<SPSTagTs...>>(Args...);
300310
if (const char *ErrMsg = ArgBuffer.getOutOfBandError())
301311
return make_error<StringError>(ErrMsg);
302312

303-
WrapperFunctionResult ResultBuffer =
304-
Dispatch(ArgBuffer.data(), ArgBuffer.size());
305-
313+
WrapperFunctionResult ResultBuffer = __orc_rt_jit_dispatch(
314+
&__orc_rt_jit_dispatch_ctx, FnTag, ArgBuffer.data(), ArgBuffer.size());
306315
if (auto ErrMsg = ResultBuffer.getOutOfBandError())
307316
return make_error<StringError>(ErrMsg);
308317

0 commit comments

Comments
 (0)