LLVM  16.0.0git
OrcError.cpp
Go to the documentation of this file.
1 //===---------------- OrcError.cpp - Error codes for ORC ------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Error codes for ORC.
10 //
11 //===----------------------------------------------------------------------===//
12 
15 
16 #include <type_traits>
17 
18 using namespace llvm;
19 using namespace llvm::orc;
20 
21 namespace {
22 
23 // FIXME: This class is only here to support the transition to llvm::Error. It
24 // will be removed once this transition is complete. Clients should prefer to
25 // deal with the Error value directly, rather than converting to error_code.
26 class OrcErrorCategory : public std::error_category {
27 public:
28  const char *name() const noexcept override { return "orc"; }
29 
30  std::string message(int condition) const override {
31  switch (static_cast<OrcErrorCode>(condition)) {
33  return "Unknown ORC error";
35  return "Duplicate symbol definition";
37  return "JIT symbol not found";
39  return "Remote allocator does not exist";
41  return "Remote allocator Id already in use";
43  return "Remote mprotect call references unallocated memory";
45  return "Remote indirect stubs owner does not exist";
47  return "Remote indirect stubs owner Id already in use";
49  return "RPC connection closed";
51  return "Could not negotiate RPC function";
53  return "RPC response abandoned";
55  return "Unexpected RPC call";
57  return "Unexpected RPC response";
59  return "Unknown error returned from remote RPC function "
60  "(Use StringError to get error message)";
62  return "Unknown resource handle";
64  return "MissingSymbolsDefinitions";
66  return "UnexpectedSymbolDefinitions";
67  }
68  llvm_unreachable("Unhandled error code");
69  }
70 };
71 
72 OrcErrorCategory &getOrcErrCat() {
73  static OrcErrorCategory OrcErrCat;
74  return OrcErrCat;
75 }
76 } // namespace
77 
78 namespace llvm {
79 namespace orc {
80 
82 char JITSymbolNotFound::ID = 0;
83 
84 std::error_code orcError(OrcErrorCode ErrCode) {
85  typedef std::underlying_type_t<OrcErrorCode> UT;
86  return std::error_code(static_cast<UT>(ErrCode), getOrcErrCat());
87 }
88 
91 
92 std::error_code DuplicateDefinition::convertToErrorCode() const {
94 }
95 
97  OS << "Duplicate definition of symbol '" << SymbolName << "'";
98 }
99 
100 const std::string &DuplicateDefinition::getSymbolName() const {
101  return SymbolName;
102 }
103 
105  : SymbolName(std::move(SymbolName)) {}
106 
107 std::error_code JITSymbolNotFound::convertToErrorCode() const {
108  typedef std::underlying_type_t<OrcErrorCode> UT;
109  return std::error_code(static_cast<UT>(OrcErrorCode::JITSymbolNotFound),
110  getOrcErrCat());
111 }
112 
114  OS << "Could not find symbol '" << SymbolName << "'";
115 }
116 
117 const std::string &JITSymbolNotFound::getSymbolName() const {
118  return SymbolName;
119 }
120 
121 } // namespace orc
122 } // namespace llvm
llvm::orc::DuplicateDefinition::getSymbolName
const std::string & getSymbolName() const
Definition: OrcError.cpp:100
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::orc::JITSymbolNotFound::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: OrcError.cpp:113
llvm::orc::JITSymbolNotFound::ID
static char ID
Definition: OrcError.h:61
name
static const char * name
Definition: SMEABIPass.cpp:49
llvm::orc::OrcErrorCode::JITSymbolNotFound
@ JITSymbolNotFound
ErrorHandling.h
llvm::orc::OrcErrorCode::UnknownORCError
@ UnknownORCError
llvm::orc::OrcErrorCode::RPCConnectionClosed
@ RPCConnectionClosed
llvm::orc::OrcErrorCode::DuplicateDefinition
@ DuplicateDefinition
llvm::orc::OrcErrorCode::RemoteIndirectStubsOwnerDoesNotExist
@ RemoteIndirectStubsOwnerDoesNotExist
llvm::orc::JITSymbolNotFound::getSymbolName
const std::string & getSymbolName() const
Definition: OrcError.cpp:117
llvm::orc::orcError
std::error_code orcError(OrcErrorCode ErrCode)
Definition: OrcError.cpp:84
llvm::orc::OrcErrorCode::RemoteAllocatorIdAlreadyInUse
@ RemoteAllocatorIdAlreadyInUse
llvm::orc::OrcErrorCode::RPCCouldNotNegotiateFunction
@ RPCCouldNotNegotiateFunction
llvm::orc
Definition: COFFPlatform.h:30
llvm::orc::OrcErrorCode::UnexpectedSymbolDefinitions
@ UnexpectedSymbolDefinitions
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
llvm::orc::DuplicateDefinition::ID
static char ID
Definition: OrcError.h:49
llvm::orc::OrcErrorCode::RPCResponseAbandoned
@ RPCResponseAbandoned
llvm::orc::OrcErrorCode
OrcErrorCode
Definition: OrcError.h:24
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::orc::OrcErrorCode::RemoteAllocatorDoesNotExist
@ RemoteAllocatorDoesNotExist
llvm::orc::OrcErrorCode::UnknownResourceHandle
@ UnknownResourceHandle
llvm::orc::OrcErrorCode::RemoteMProtectAddrUnrecognized
@ RemoteMProtectAddrUnrecognized
message
message(STATUS "Targeting ${t}") add_subdirectory($
Definition: CMakeLists.txt:34
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1861
llvm::orc::OrcErrorCode::RemoteIndirectStubsOwnerIdAlreadyInUse
@ RemoteIndirectStubsOwnerIdAlreadyInUse
llvm::orc::JITSymbolNotFound::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: OrcError.cpp:107
llvm::orc::JITSymbolNotFound::JITSymbolNotFound
JITSymbolNotFound(std::string SymbolName)
Definition: OrcError.cpp:104
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::orc::DuplicateDefinition::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: OrcError.cpp:96
llvm::AMDGPU::HSAMD::Kernel::Key::SymbolName
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
Definition: AMDGPUMetadata.h:386
llvm::orc::OrcErrorCode::UnexpectedRPCCall
@ UnexpectedRPCCall
std
Definition: BitVector.h:851
llvm::orc::OrcErrorCode::UnknownErrorCodeFromRemote
@ UnknownErrorCodeFromRemote
llvm::orc::OrcErrorCode::UnexpectedRPCResponse
@ UnexpectedRPCResponse
llvm::orc::DuplicateDefinition::DuplicateDefinition
DuplicateDefinition(std::string SymbolName)
Definition: OrcError.cpp:89
llvm::orc::DuplicateDefinition::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: OrcError.cpp:92
llvm::orc::OrcErrorCode::MissingSymbolDefinitions
@ MissingSymbolDefinitions
OrcError.h