1//===----------- JITSymbol.cpp - JITSymbol class implementation -----------===// 
  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 
  7//===----------------------------------------------------------------------===// 
  9// JITSymbol class implementation plus helper functions. 
  11//===----------------------------------------------------------------------===// 
  23 assert(GV.
hasName() && 
"Can't get flags for anonymous symbol");
 
  39 // Check for a linker-private-global-prefix on the symbol name, in which 
  40 // case it must be marked as non-exported. 
  42 const auto &
DL = M->getDataLayout();
 
 
  71 if (!SymbolFlagsOrErr)
 
  72 // TODO: Test this error. 
 
  96 if (!SymbolFlagsOrErr)
 
  97 // TODO: Actually report errors helpfully. 
 
  105/// Performs lookup by, for each symbol, first calling 
  106/// findSymbolInLogicalDylib and if that fails calling 
  111 for (
auto &Symbol : Symbols) {
 
  112 std::string SymName = Symbol.str();
 
  114 if (
auto AddrOrErr = Sym.getAddress())
 
  117 OnResolved(AddrOrErr.takeError());
 
  120 } 
else if (
auto Err = Sym.takeError()) {
 
  121 OnResolved(std::move(Err));
 
  124 // findSymbolInLogicalDylib failed. Lets try findSymbol. 
  126 if (
auto AddrOrErr = Sym.getAddress())
 
  129 OnResolved(AddrOrErr.takeError());
 
  132 } 
else if (
auto Err = Sym.takeError()) {
 
  133 OnResolved(std::move(Err));
 
  143 OnResolved(std::move(Result));
 
 
  146/// Performs flags lookup by calling findSymbolInLogicalDylib and 
  147/// returning the flags value for that symbol. 
  152 for (
auto &Symbol : Symbols) {
 
  153 std::string SymName = Symbol.str();
 
  155 // If there's an existing def but it is not strong, then the caller is 
  156 // responsible for it. 
  157 if (!Sym.getFlags().isStrong())
 
  158 Result.insert(Symbol);
 
  159 } 
else if (
auto Err = Sym.takeError())
 
  160 return std::move(Err);
 
  162 // If there is no existing definition then the caller is responsible for 
  164 Result.insert(Symbol);
 
  168 return std::move(Result);
 
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
 
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
 
ARM-specific JIT symbol flags.
 
static LLVM_ABI ARMJITSymbolFlags fromObjectSymbol(const object::SymbolRef &Symbol)
 
ARMJITSymbolFlags()=default
 
Tagged union holding either a T or a Error.
 
Error takeError()
Take ownership of the stored error.
 
Function and variable summary information to aid decisions and implementation of importing.
 
GlobalValue::LinkageTypes linkage() const
Return linkage type recorded for this global value.
 
bool hasLinkOnceLinkage() const
 
static bool isExternalWeakLinkage(LinkageTypes Linkage)
 
bool hasLocalLinkage() const
 
static bool isLinkOnceLinkage(LinkageTypes Linkage)
 
bool hasHiddenVisibility() const
 
Module * getParent()
Get the module that this global value is contained inside of...
 
static bool isCommonLinkage(LinkageTypes Linkage)
 
static bool isExternalLinkage(LinkageTypes Linkage)
 
bool hasWeakLinkage() const
 
bool hasCommonLinkage() const
 
static bool isWeakLinkage(LinkageTypes Linkage)
 
Represents a symbol that has been evaluated to an address already.
 
static LLVM_ABI Expected< JITSymbolFlags > fromObjectSymbol(const object::SymbolRef &Symbol)
Construct a JITSymbolFlags value based on the flags of the given libobject symbol.
 
JITSymbolFlags()=default
Default-construct a JITSymbolFlags instance.
 
static LLVM_ABI JITSymbolFlags fromSummary(GlobalValueSummary *S)
Construct a JITSymbolFlags value based on the flags of the given global value summary.
 
static LLVM_ABI JITSymbolFlags fromGlobalValue(const GlobalValue &GV)
Construct a JITSymbolFlags value based on the flags of the given global value.
 
unique_function< void(Expected< LookupResult >)> OnResolvedFunction
 
std::map< StringRef, JITEvaluatedSymbol > LookupResult
 
std::set< StringRef > LookupSet
 
virtual JITSymbol findSymbol(const std::string &Name)=0
This method returns the address of the specified function or variable.
 
Expected< LookupSet > getResponsibilitySet(const LookupSet &Symbols) final
Performs flags lookup by calling findSymbolInLogicalDylib and returning the flags value for that symb...
 
virtual JITSymbol findSymbolInLogicalDylib(const std::string &Name)=0
This method returns the address of the specified symbol if it exists within the logical dynamic libra...
 
void lookup(const LookupSet &Symbols, OnResolvedFunction OnResolved) final
Performs lookup by, for each symbol, first calling findSymbolInLogicalDylib and if that fails calling...
 
StringRef - Represent a constant reference to a string, i.e.
 
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
 
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
 
constexpr bool empty() const
empty - Check if the string is empty.
 
char front() const
front - Get the first character in the string.
 
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
 
This is a value type class that represents a single symbol in the list of symbols in the object file.
 
This is an optimization pass for GlobalISel generic memory operations.
 
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
 
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
 
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
 
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
 
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.