Path: blob/main/contrib/llvm-project/compiler-rt/lib/orc/resolve.cpp
213766 views
//===- resolve.cpp --------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file contains a generic "resolver" function compatible with the9// __orc_rt_reenter function.10//11//===----------------------------------------------------------------------===//1213#include "executor_symbol_def.h"14#include "jit_dispatch.h"15#include "wrapper_function_utils.h"1617#include <stdio.h>1819#define DEBUG_TYPE "resolve"2021using namespace orc_rt;2223// Declare function tags for functions in the JIT process.24ORC_RT_JIT_DISPATCH_TAG(__orc_rt_resolve_tag)2526// FIXME: Make this configurable via an alias.27static void __orc_rt_resolve_fail(void *Caller, const char *ErrMsg) {28fprintf(stderr, "error resolving implementation for stub %p: %s\n", Caller,29ErrMsg);30abort();31}3233extern "C" ORC_RT_HIDDEN void *__orc_rt_resolve(void *Caller) {34Expected<ExecutorSymbolDef> Result((ExecutorSymbolDef()));35if (auto Err = WrapperFunction<SPSExpected<SPSExecutorSymbolDef>(36SPSExecutorAddr)>::call(JITDispatch(&__orc_rt_resolve_tag), Result,37ExecutorAddr::fromPtr(Caller))) {38__orc_rt_resolve_fail(Caller, toString(std::move(Err)).c_str());39return nullptr; // Unreachable.40}4142if (!Result) {43__orc_rt_resolve_fail(Caller, toString(Result.takeError()).c_str());44return nullptr; // Unreachable.45}4647return Result->getAddress().toPtr<void *>();48}495051