[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 a356b813150f3aa88bc8cda250ed3a770ecabf96..0f0fa6cae3162020a4817b0fc74b470672d615fc 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 6dc561b5f633f323e5722b843cdf92d7611ccdbc..79358ab5db76462b88c7042c6e86a15be605460d 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 89bcc6e8f0db33ec0d06a4558314792b5b528aa6..0d234e421149d54100269710ade34002e7f67d88 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 890c9673eeb1e55faf0e4205cb109a1e01a27211..3fcacde3644ed0208194ec788de12d1c44202030 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 7ae2d604d340bf37ff4ca9b6584f9432982ba77d..8bd762460dd27dcb7e0df7f39bb6fba326c35588 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 648224184a7d0b64ceff9b13904900b7812a0b67..0494705b462de626c3d6fbc70e2701912dff3502 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 dc6854756381bd4d6b96de7bce73e77bbf189c3b..2982a7af09b0563bc891865586be8b60c563f81a 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 cf0517b2b1ad6ad83da8e710ebb61c9dcaa79ea8..6ca47d1c9a2acf8b2ad647dd308952055afa5cee 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 2db6e1772ad187c869236a60c13ba31de50c62e6..b518d89dd7d4ac1563db309a7ece32f16b4bf779 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 fa29aca3e1405f1e796035dfb11a824a92109842..b555669906c9a98a9b36c4ddffbd618d12bb6ecf 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 cb867986177ddb1f82ff471cf1b0331f9f3d065c..7ef09fdce8a4492f6b4aeac9390d08f24eb31453 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 37fe44d5fa69e522e9e4a2d5e3a773461502b856..f094c02e86f34822c74aed531496ae7b8d1f3385 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 58c8341c07c95404d3bd3f68cfb6fdf32f9d72c9..0c0a1a536deb0a9d18d70206958d58c2c9d032a6 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 7cbc9f33b182c48f2cec50e3e21a563f8d09afd1..ba6cfaf8aa94731811925bf4209e7eb62c0e7c9d 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 642aa74bd484932fcd40555c0c2a13a68cbf1c2e..40716a7f9b61192eab98239f49c67c78dd23f528 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 9386a037950411b1017be5a4098374af4d6502e5..6448adaa0ceb36f18b7fa6b208599616635f6e19 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 eb24221b0c16e12014b517f31f5b70769964b07c..00032e4dca3fe8a2ac3795903bb0846c57d85d0c 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 b980b5055cc65bdd0edd2c45844cf6919a5bea10..30d641ee00cf85e4f55bf2dd11d5e82d1e31f51a 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 37dea5ca056a446d1e86ae7c9f3a14731772d1fe..3aa94a7f43e2e5fcf292b34f618bb8f4ab155f01 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 fb458c288c1b5a3ce94fac5fab2f91f03b03b6de..7ba03869d8304575ba50f48a7da1f54fe3330b70 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 b76b745cee9bcf092f24b3fb2988df9fee0d4e3f..7546b3f8d0fa548e558a25c7add596c86ecdcae5 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 ac9d4d4602174662c8b2ec2ba1e4205e40a40f39..f564b0035bffdec1290d2d0fec19ca0ab7657e5a 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 59e7bda3b1015481f6eb4a6b063ad45828733347..aee6f20246f74fe61fa712a6de89d4febfd4f1d0 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());