ReOptimizeLayer was building LLVM IR to define a precomputed, SPS-serialized argument buffer, then inserting calls directly to __orc_rt_jit_dispatch, passing the address of the precomputed buffer and an __orc_rt_reoptimize_tag defined by the ORC runtime. This design is non-canonical, requiring the ORC runtime to be loaded (or an extra definition for __orc_rt_reoptimize_tag to be inserted) while not using the runtime to perform the serialization. This commit updates ReOptimizeLayer to instead insert calls to an __orc_rt_reoptimize function implemented in the ORC runtime. This function will perform serialization and call __orc_rt_jit_dispatch, similar to other functions in the ORC runtime. To maintain support for in-process JITs that don't use the ORC runtime, this commit adds a ReOptimizeLayer::addOrcRTLiteSupport method which injects IR to define __orc_rt_reoptimize (calling through to an orc_rt_lite_reoptimize_helper function defined in LLVM) and __orc_rt_reoptimize_tag. The ReOptimizeLayerTest is updated to use addOrcRTLiteSupport.
28 lines
1.1 KiB
C++
28 lines
1.1 KiB
C++
//===- reoptimize.cpp -----------------------------------------------------===//
|
|
//
|
|
// 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 contains code required to load the rest of the ELF-on-*IX runtime.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "jit_dispatch.h"
|
|
#include "wrapper_function_utils.h"
|
|
|
|
using namespace orc_rt;
|
|
|
|
ORC_RT_JIT_DISPATCH_TAG(__orc_rt_reoptimize_tag)
|
|
|
|
ORC_RT_INTERFACE void __orc_rt_reoptimize(uint64_t MUID, uint32_t CurVersion) {
|
|
if (auto Err = WrapperFunction<void(uint64_t, uint32_t)>::call(
|
|
JITDispatch(&__orc_rt_reoptimize_tag), MUID, CurVersion)) {
|
|
__orc_rt_log_error(toString(std::move(Err)).c_str());
|
|
// FIXME: Should we abort here? Depending on the error we can't guarantee
|
|
// that the JIT'd code is in a consistent state.
|
|
}
|
|
}
|