#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
+#include <optional>
#include <map>
#include <string>
}
/// Cache type for the splitBlock function.
- using SplitBlockCache = Optional<SmallVector<Symbol *, 8>>;
+ using SplitBlockCache = std::optional<SmallVector<Symbol *, 8>>;
/// Splits block B at the given index which must be greater than zero.
/// If SplitIndex == B.getSize() then this function is a no-op and returns B.
/// given offset) of the size of the new block.
///
/// All other symbol attributes are unchanged.
- void transferDefinedSymbol(Symbol &Sym, Block &DestBlock,
- orc::ExecutorAddrDiff NewOffset,
- Optional<orc::ExecutorAddrDiff> ExplicitNewSize) {
+ void
+ transferDefinedSymbol(Symbol &Sym, Block &DestBlock,
+ orc::ExecutorAddrDiff NewOffset,
+ std::optional<orc::ExecutorAddrDiff> ExplicitNewSize) {
auto &OldSection = Sym.getBlock().getSection();
Sym.setBlock(DestBlock);
Sym.setOffset(NewOffset);
JITDylib &PlatformJD, const char *OrcRuntimePath,
LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime = false,
const char *VCRuntimePath = nullptr,
- Optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
+ std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
ExecutionSession &getExecutionSession() const { return ES; }
ObjectLinkingLayer &getObjectLinkingLayer() const { return ObjLinkingLayer; }
#define LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
#include "llvm/ADT/APInt.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
#include "llvm/ExecutionEngine/Orc/Layer.h"
#include "llvm/ExecutionEngine/Orc/LazyReexports.h"
-#include "llvm/ExecutionEngine/Orc/Speculation.h"
#include "llvm/ExecutionEngine/Orc/Shared/OrcError.h"
+#include "llvm/ExecutionEngine/Orc/Speculation.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Constant.h"
#include <iterator>
#include <list>
#include <memory>
+#include <optional>
#include <set>
#include <utility>
#include <vector>
/// Partitioning function.
using PartitionFunction =
- std::function<Optional<GlobalValueSet>(GlobalValueSet Requested)>;
+ std::function<std::optional<GlobalValueSet>(GlobalValueSet Requested)>;
/// Off-the-shelf partitioning which compiles all requested symbols (usually
/// a single function at a time).
- static Optional<GlobalValueSet> compileRequested(GlobalValueSet Requested);
+ static std::optional<GlobalValueSet>
+ compileRequested(GlobalValueSet Requested);
/// Off-the-shelf partitioning which compiles whole modules whenever any
/// symbol in them is requested.
- static Optional<GlobalValueSet> compileWholeModule(GlobalValueSet Requested);
+ static std::optional<GlobalValueSet>
+ compileWholeModule(GlobalValueSet Requested);
/// Construct a CompileOnDemandLayer.
CompileOnDemandLayer(ExecutionSession &ES, IRLayer &BaseLayer,
static Expected<std::unique_ptr<ELFNixPlatform>>
Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD, const char *OrcRuntimePath,
- Optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
+ std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
ExecutionSession &getExecutionSession() const { return ES; }
ObjectLinkingLayer &getObjectLinkingLayer() const { return ObjLinkingLayer; }
/// loaded to find the registration functions.
Expected<std::unique_ptr<EPCDebugObjectRegistrar>> createJITLoaderGDBRegistrar(
ExecutionSession &ES,
- Optional<ExecutorAddr> RegistrationFunctionDylib = std::nullopt);
+ std::optional<ExecutorAddr> RegistrationFunctionDylib = std::nullopt);
} // end namespace orc
} // end namespace llvm
/// will be loaded to find the registration functions.
static Expected<std::unique_ptr<EPCEHFrameRegistrar>>
Create(ExecutionSession &ES,
- Optional<ExecutorAddr> RegistrationFunctionsDylib = std::nullopt);
+ std::optional<ExecutorAddr> RegistrationFunctionsDylib = std::nullopt);
/// Create a EPCEHFrameRegistrar with the given ExecutorProcessControl
/// object and registration/deregistration function addresses.
std::unique_ptr<ExecutorProcessControl> EPC;
std::unique_ptr<ExecutionSession> ES;
- Optional<JITTargetMachineBuilder> JTMB;
- Optional<DataLayout> DL;
+ std::optional<JITTargetMachineBuilder> JTMB;
+ std::optional<DataLayout> DL;
ObjectLinkingLayerCreator CreateObjectLinkingLayer;
CompileFunctionCreator CreateCompileFunction;
PlatformSetupFunction SetUpPlatform;
/// Return a reference to the JITTargetMachineBuilder.
///
- Optional<JITTargetMachineBuilder> &getJITTargetMachineBuilder() {
+ std::optional<JITTargetMachineBuilder> &getJITTargetMachineBuilder() {
return impl().JTMB;
}
/// Set a DataLayout for this instance. If no data layout is specified then
/// the target's default data layout will be used.
- SetterImpl &setDataLayout(Optional<DataLayout> DL) {
+ SetterImpl &setDataLayout(std::optional<DataLayout> DL) {
impl().DL = std::move(DL);
return impl();
}
static Expected<std::unique_ptr<MachOPlatform>>
Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD, const char *OrcRuntimePath,
- Optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
+ std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
ExecutionSession &getExecutionSession() const { return ES; }
ObjectLinkingLayer &getObjectLinkingLayer() const { return ObjLinkingLayer; }
bool isStraightLine(const Function &F);
public:
- using ResultTy = Optional<DenseMap<StringRef, DenseSet<StringRef>>>;
+ using ResultTy = std::optional<DenseMap<StringRef, DenseSet<StringRef>>>;
};
// Direct calls in high frequency basic blocks are extracted.
private:
// FIX ME: find a right way to distinguish the pre-compile Symbols, and update
// the callsite
- Optional<AliaseeDetails> getImplFor(const SymbolStringPtr &StubSymbol) {
+ std::optional<AliaseeDetails> getImplFor(const SymbolStringPtr &StubSymbol) {
std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
auto Position = Maps.find(StubSymbol);
if (Position != Maps.end())
class IRSpeculationLayer : public IRLayer {
public:
- using IRlikiesStrRef = Optional<DenseMap<StringRef, DenseSet<StringRef>>>;
+ using IRlikiesStrRef =
+ std::optional<DenseMap<StringRef, DenseSet<StringRef>>>;
using ResultEval = std::function<IRlikiesStrRef(Function &)>;
using TargetAndLikelies = DenseMap<SymbolStringPtr, SymbolNameSet>;
/// many main functions will expect a name argument at least, and will fail
/// if none is provided.
int runAsMain(int (*Main)(int, char *[]), ArrayRef<std::string> Args,
- Optional<StringRef> ProgramName = std::nullopt);
+ std::optional<StringRef> ProgramName = std::nullopt);
int runAsVoidFunction(int (*Func)(void));
int runAsIntFunction(int (*Func)(int), int Arg);
#define LLVM_EXECUTIONENGINE_RUNTIMEDYLDCHECKER_H
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/Support/Endian.h"
+#include <optional>
#include <cstdint>
#include <memory>
/// If there is a section at the given local address, return its load
/// address, otherwise return none.
- Optional<uint64_t> getSectionLoadAddress(void *LocalAddress) const;
+ std::optional<uint64_t> getSectionLoadAddress(void *LocalAddress) const;
private:
std::unique_ptr<RuntimeDyldCheckerImpl> Impl;
jitlink::Linkage Linkage;
orc::ExecutorAddrDiff Size;
};
- std::vector<Optional<ComdatExportRequest>> PendingComdatExports;
+ std::vector<std::optional<ComdatExportRequest>> PendingComdatExports;
// This represents a pending request to create a weak external symbol with a
// name.
friend class MachOLinkGraphBuilder;
private:
- NormalizedSymbol(Optional<StringRef> Name, uint64_t Value, uint8_t Type,
- uint8_t Sect, uint16_t Desc, Linkage L, Scope S)
+ NormalizedSymbol(std::optional<StringRef> Name, uint64_t Value,
+ uint8_t Type, uint8_t Sect, uint16_t Desc, Linkage L,
+ Scope S)
: Name(Name), Value(Value), Type(Type), Sect(Sect), Desc(Desc), L(L),
S(S) {
assert((!Name || !Name->empty()) && "Name must be none or non-empty");
NormalizedSymbol(NormalizedSymbol &&) = delete;
NormalizedSymbol &operator=(NormalizedSymbol &&) = delete;
- Optional<StringRef> Name;
+ std::optional<StringRef> Name;
uint64_t Value = 0;
uint8_t Type = 0;
uint8_t Sect = 0;
JITDylib &PlatformJD, const char *OrcRuntimePath,
LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
const char *VCRuntimePath,
- Optional<SymbolAliasMap> RuntimeAliases) {
+ std::optional<SymbolAliasMap> RuntimeAliases) {
auto &EPC = ES.getExecutorProcessControl();
// If the target is not supported then bail out immediately.
CompileOnDemandLayer &Parent;
};
-Optional<CompileOnDemandLayer::GlobalValueSet>
+std::optional<CompileOnDemandLayer::GlobalValueSet>
CompileOnDemandLayer::compileRequested(GlobalValueSet Requested) {
return std::move(Requested);
}
-Optional<CompileOnDemandLayer::GlobalValueSet>
+std::optional<CompileOnDemandLayer::GlobalValueSet>
CompileOnDemandLayer::compileWholeModule(GlobalValueSet Requested) {
return std::nullopt;
}
ELFNixPlatform::Create(ExecutionSession &ES,
ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD, const char *OrcRuntimePath,
- Optional<SymbolAliasMap> RuntimeAliases) {
+ std::optional<SymbolAliasMap> RuntimeAliases) {
auto &EPC = ES.getExecutorProcessControl();
namespace llvm {
namespace orc {
-Expected<std::unique_ptr<EPCDebugObjectRegistrar>>
-createJITLoaderGDBRegistrar(ExecutionSession &ES,
- Optional<ExecutorAddr> RegistrationFunctionDylib) {
+Expected<std::unique_ptr<EPCDebugObjectRegistrar>> createJITLoaderGDBRegistrar(
+ ExecutionSession &ES,
+ std::optional<ExecutorAddr> RegistrationFunctionDylib) {
auto &EPC = ES.getExecutorProcessControl();
if (!RegistrationFunctionDylib) {
namespace llvm {
namespace orc {
-Expected<std::unique_ptr<EPCEHFrameRegistrar>>
-EPCEHFrameRegistrar::Create(ExecutionSession &ES,
- Optional<ExecutorAddr> RegistrationFunctionsDylib) {
+Expected<std::unique_ptr<EPCEHFrameRegistrar>> EPCEHFrameRegistrar::Create(
+ ExecutionSession &ES,
+ std::optional<ExecutorAddr> RegistrationFunctionsDylib) {
// FIXME: Proper mangling here -- we really need to decouple linker mangling
// from DataLayout.
Expected<std::unique_ptr<MachOPlatform>>
MachOPlatform::Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD, const char *OrcRuntimePath,
- Optional<SymbolAliasMap> RuntimeAliases) {
+ std::optional<SymbolAliasMap> RuntimeAliases) {
auto &EPC = ES.getExecutorProcessControl();
namespace orc {
int runAsMain(int (*Main)(int, char *[]), ArrayRef<std::string> Args,
- Optional<StringRef> ProgramName) {
+ std::optional<StringRef> ProgramName) {
std::vector<std::unique_ptr<char[]>> ArgVStorage;
std::vector<char *> ArgV;
getStubOrGOTAddrFor(StringRef StubContainerName, StringRef Symbol,
bool IsInsideLoad, bool IsStubAddr) const;
- Optional<uint64_t> getSectionLoadAddress(void *LocalAddr) const;
+ std::optional<uint64_t> getSectionLoadAddress(void *LocalAddr) const;
IsSymbolValidFunction IsSymbolValid;
GetSymbolInfoFunction GetSymbolInfo;
// Get TargetTriple and DataLayout from the main module if they're explicitly
// set.
std::optional<Triple> TT;
- Optional<DataLayout> DL;
+ std::optional<DataLayout> DL;
MainModule.withModuleDo([&](Module &M) {
if (!M.getTargetTriple().empty())
TT = Triple(M.getTargetTriple());