[ExecutionEngine] llvm::Optional => std::optional
authorFangrui Song <i@maskray.me>
Wed, 14 Dec 2022 10:18:07 +0000 (10:18 +0000)
committerFangrui Song <i@maskray.me>
Wed, 14 Dec 2022 10:18:08 +0000 (10:18 +0000)
23 files changed:
llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
llvm/include/llvm/ExecutionEngine/Orc/COFFPlatform.h
llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
llvm/include/llvm/ExecutionEngine/Orc/ELFNixPlatform.h
llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h
llvm/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h
llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h
llvm/include/llvm/ExecutionEngine/Orc/SpeculateAnalyses.h
llvm/include/llvm/ExecutionEngine/Orc/Speculation.h
llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.h
llvm/include/llvm/ExecutionEngine/RuntimeDyldChecker.h
llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.h
llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.h
llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp
llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp
llvm/lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp
llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
llvm/lib/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCheckerImpl.h
llvm/tools/lli/lli.cpp

index a356b81..0f0fa6c 100644 (file)
@@ -15,7 +15,6 @@
 
 #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"
@@ -29,6 +28,7 @@
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include <optional>
 
 #include <map>
 #include <string>
@@ -1071,7 +1071,7 @@ public:
   }
 
   /// 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.
@@ -1302,9 +1302,10 @@ public:
   /// 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);
index 6dc561b..79358ab 100644 (file)
@@ -44,7 +44,7 @@ public:
          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; }
index 89bcc6e..0d234e4 100644 (file)
 #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"
@@ -45,6 +44,7 @@
 #include <iterator>
 #include <list>
 #include <memory>
+#include <optional>
 #include <set>
 #include <utility>
 #include <vector>
@@ -64,15 +64,17 @@ public:
 
   /// 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,
index 890c967..3fcacde 100644 (file)
@@ -95,7 +95,7 @@ public:
   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; }
index 7ae2d60..8bd7624 100644 (file)
@@ -58,7 +58,7 @@ private:
 /// 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
index 6482241..0494705 100644 (file)
@@ -34,7 +34,7 @@ public:
   /// 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.
index dc68547..2982a7a 100644 (file)
@@ -262,8 +262,8 @@ public:
 
   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;
@@ -305,13 +305,13 @@ public:
 
   /// 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();
   }
index cf0517b..6ca47d1 100644 (file)
@@ -80,7 +80,7 @@ public:
   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; }
index 2db6e17..b518d89 100644 (file)
@@ -31,7 +31,7 @@ protected:
   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.
index fa29aca..b555669 100644 (file)
@@ -44,7 +44,7 @@ public:
 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())
@@ -171,7 +171,8 @@ private:
 
 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>;
 
index cb86798..7ef09fd 100644 (file)
@@ -30,7 +30,7 @@ namespace orc {
 /// 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);
index 37fe44d..f094c02 100644 (file)
@@ -10,9 +10,9 @@
 #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>
@@ -173,7 +173,7 @@ public:
 
   /// 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;
index 58c8341..0c0a1a5 100644 (file)
@@ -115,7 +115,7 @@ private:
     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.
index 7cbc9f3..ba6cfaf 100644 (file)
@@ -37,8 +37,9 @@ protected:
     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");
@@ -50,7 +51,7 @@ protected:
     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;
index 642aa74..40716a7 100644 (file)
@@ -164,7 +164,7 @@ COFFPlatform::Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
                      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.
index 9386a03..6448ada 100644 (file)
@@ -102,12 +102,12 @@ private:
   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;
 }
index eb24221..00032e4 100644 (file)
@@ -111,7 +111,7 @@ Expected<std::unique_ptr<ELFNixPlatform>>
 ELFNixPlatform::Create(ExecutionSession &ES,
                        ObjectLinkingLayer &ObjLinkingLayer,
                        JITDylib &PlatformJD, const char *OrcRuntimePath,
-                       Optional<SymbolAliasMap> RuntimeAliases) {
+                       std::optional<SymbolAliasMap> RuntimeAliases) {
 
   auto &EPC = ES.getExecutorProcessControl();
 
index b980b50..30d641e 100644 (file)
@@ -16,9 +16,9 @@
 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) {
index 37dea5c..3aa94a7 100644 (file)
@@ -16,9 +16,9 @@ using namespace llvm::orc::shared;
 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.
 
index fb458c2..7ba0386 100644 (file)
@@ -190,7 +190,7 @@ namespace orc {
 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();
 
index b76b745..7546b3f 100644 (file)
@@ -14,7 +14,7 @@ namespace llvm {
 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;
 
index ac9d4d4..f564b00 100644 (file)
@@ -57,7 +57,7 @@ private:
   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;
index 59e7bda..aee6f20 100644 (file)
@@ -846,7 +846,7 @@ int runOrcJIT(const char *ProgName) {
   // 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());