From 4e62072ca1ee4ecb7584ba9a69464ba617eaae61 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 4 Dec 2022 20:44:52 +0000 Subject: [PATCH] [Passes] llvm::Optional => std::optional --- clang/lib/CodeGen/BackendUtil.cpp | 2 +- llvm/include/llvm/Passes/PassBuilder.h | 6 +++--- llvm/include/llvm/Passes/StandardInstrumentations.h | 2 +- llvm/include/llvm/Target/TargetMachine.h | 7 +++---- llvm/lib/CodeGen/TargetPassConfig.cpp | 4 ++-- llvm/lib/LTO/LTOBackend.cpp | 2 +- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 2 +- llvm/lib/Passes/PassBuilder.cpp | 4 ++-- llvm/tools/opt/NewPMDriver.cpp | 2 +- 9 files changed, 15 insertions(+), 16 deletions(-) diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 15e78908a6e8..b18ead066c6d 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -773,7 +773,7 @@ static void addSanitizers(const Triple &TargetTriple, void EmitAssemblyHelper::RunOptimizationPipeline( BackendAction Action, std::unique_ptr &OS, std::unique_ptr &ThinLinkOS) { - Optional PGOOpt; + std::optional PGOOpt; if (CodeGenOpts.hasProfileIRInstr()) // -fprofile-generate. diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h index d7a0e7726cc3..2e9f805faa51 100644 --- a/llvm/include/llvm/Passes/PassBuilder.h +++ b/llvm/include/llvm/Passes/PassBuilder.h @@ -97,7 +97,7 @@ public: class PassBuilder { TargetMachine *TM; PipelineTuningOptions PTO; - Optional PGOOpt; + std::optional PGOOpt; PassInstrumentationCallbacks *PIC; public: @@ -116,7 +116,7 @@ public: explicit PassBuilder(TargetMachine *TM = nullptr, PipelineTuningOptions PTO = PipelineTuningOptions(), - Optional PGOOpt = std::nullopt, + std::optional PGOOpt = std::nullopt, PassInstrumentationCallbacks *PIC = nullptr); /// Cross register the analysis managers through their proxies. @@ -587,7 +587,7 @@ private: void addVectorPasses(OptimizationLevel Level, FunctionPassManager &FPM, bool IsFullLTO); - static Optional> + static std::optional> parsePipelineText(StringRef Text); Error parseModulePass(ModulePassManager &MPM, const PipelineElement &E); diff --git a/llvm/include/llvm/Passes/StandardInstrumentations.h b/llvm/include/llvm/Passes/StandardInstrumentations.h index 760deccbb241..20211c18b3d9 100644 --- a/llvm/include/llvm/Passes/StandardInstrumentations.h +++ b/llvm/include/llvm/Passes/StandardInstrumentations.h @@ -127,7 +127,7 @@ public: // in the Graph (BBGuard). That is if any of the block is deleted or RAUWed // then the CFG is treated poisoned and no block pointer of the Graph is used. struct CFG { - Optional> BBGuards; + std::optional> BBGuards; DenseMap> Graph; CFG(const Function *F, bool TrackBBLifetime); diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index 86066288856f..2dd1c8199513 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -13,7 +13,6 @@ #ifndef LLVM_TARGET_TARGETMACHINE_H #define LLVM_TARGET_TARGETMACHINE_H -#include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" #include "llvm/IR/DataLayout.h" @@ -111,7 +110,7 @@ protected: // Can only create subclasses. unsigned O0WantsFastISel : 1; // PGO related tunables. - Optional PGOOption = std::nullopt; + std::optional PGOOption = std::nullopt; public: const TargetOptions DefaultOptions; @@ -311,8 +310,8 @@ public: return false; } - void setPGOOption(Optional PGOOpt) { PGOOption = PGOOpt; } - const Optional &getPGOOption() const { return PGOOption; } + void setPGOOption(std::optional PGOOpt) { PGOOption = PGOOpt; } + const std::optional &getPGOOption() const { return PGOOption; } /// If the specified generic pointer could be assumed as a pointer to a /// specific address space, return that address space. diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp index 0f4a82d96631..b95d5790e10b 100644 --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/lib/CodeGen/TargetPassConfig.cpp @@ -340,7 +340,7 @@ static IdentifyingPassPtr overridePass(AnalysisID StandardID, static std::string getFSProfileFile(const TargetMachine *TM) { if (!FSProfileFile.empty()) return FSProfileFile.getValue(); - const Optional &PGOOpt = TM->getPGOOption(); + const std::optional &PGOOpt = TM->getPGOOption(); if (PGOOpt == std::nullopt || PGOOpt->Action != PGOOptions::SampleUse) return std::string(); return PGOOpt->ProfileFile; @@ -351,7 +351,7 @@ static std::string getFSProfileFile(const TargetMachine *TM) { static std::string getFSRemappingFile(const TargetMachine *TM) { if (!FSRemappingFile.empty()) return FSRemappingFile.getValue(); - const Optional &PGOOpt = TM->getPGOOption(); + const std::optional &PGOOpt = TM->getPGOOption(); if (PGOOpt == std::nullopt || PGOOpt->Action != PGOOptions::SampleUse) return std::string(); return PGOOpt->ProfileRemappingFile; diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 7a5f3a9d56bd..1c2ca253af35 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -232,7 +232,7 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, unsigned OptLevel, bool IsThinLTO, ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary) { - Optional PGOOpt; + std::optional PGOOpt; if (!Conf.SampleProfile.empty()) PGOOpt = PGOOptions(Conf.SampleProfile, "", Conf.ProfileRemapping, PGOOptions::SampleUse, PGOOptions::NoCSAction, true); diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 9f80b06bcd3a..5b137a8f8cb3 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -237,7 +237,7 @@ crossImportIntoModule(Module &TheModule, const ModuleSummaryIndex &Index, static void optimizeModule(Module &TheModule, TargetMachine &TM, unsigned OptLevel, bool Freestanding, bool DebugPassManager, ModuleSummaryIndex *Index) { - Optional PGOOpt; + std::optional PGOOpt; LoopAnalysisManager LAM; FunctionAnalysisManager FAM; CGSCCAnalysisManager CGAM; diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 7522302b2fe2..e8a17a6a962e 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -395,7 +395,7 @@ public: } // namespace PassBuilder::PassBuilder(TargetMachine *TM, PipelineTuningOptions PTO, - Optional PGOOpt, + std::optional PGOOpt, PassInstrumentationCallbacks *PIC) : TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC) { if (TM) @@ -1027,7 +1027,7 @@ static bool isLoopPassName(StringRef Name, CallbacksT &Callbacks, return callbacksAcceptPassName(Name, Callbacks); } -Optional> +std::optional> PassBuilder::parsePipelineText(StringRef Text) { std::vector ResultPipeline; diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp index 39a998ea0e47..6b66f64b1dc4 100644 --- a/llvm/tools/opt/NewPMDriver.cpp +++ b/llvm/tools/opt/NewPMDriver.cpp @@ -333,7 +333,7 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM, bool EnableDebugify, bool VerifyDIPreserve) { bool VerifyEachPass = VK == VK_VerifyEachPass; - Optional P; + std::optional P; switch (PGOKindFlag) { case InstrGen: P = PGOOptions(ProfileFile, "", "", PGOOptions::IRInstr);