From c08fad8193d3a8387f3ddd895b850b8afec928af Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 20 Dec 2022 15:53:38 -0800 Subject: [PATCH] [llvm] Remove redundant initialization of std::optional (NFC) --- llvm/include/llvm/Analysis/InlineCost.h | 2 +- llvm/include/llvm/DWP/DWP.h | 2 +- llvm/include/llvm/IR/Instructions.h | 2 +- llvm/include/llvm/LTO/Config.h | 2 +- llvm/include/llvm/Object/ELF.h | 2 +- llvm/include/llvm/Target/TargetMachine.h | 2 +- llvm/include/llvm/Transforms/IPO/Attributor.h | 2 +- llvm/include/llvm/Transforms/Scalar/GVN.h | 10 +++++----- llvm/lib/Analysis/InlineCost.cpp | 2 +- llvm/lib/Analysis/MemorySSA.cpp | 2 +- llvm/lib/IR/DebugInfo.cpp | 2 +- llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp | 2 +- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 2 +- llvm/unittests/IR/DebugInfoTest.cpp | 4 ++-- llvm/unittests/IR/MetadataTest.cpp | 4 ++-- 15 files changed, 21 insertions(+), 21 deletions(-) diff --git a/llvm/include/llvm/Analysis/InlineCost.h b/llvm/include/llvm/Analysis/InlineCost.h index 7e56789..57f4528 100644 --- a/llvm/include/llvm/Analysis/InlineCost.h +++ b/llvm/include/llvm/Analysis/InlineCost.h @@ -102,7 +102,7 @@ class InlineCost { const char *Reason = nullptr; /// The cost-benefit pair computed by cost-benefit analysis. - std::optional CostBenefit = std::nullopt; + std::optional CostBenefit; // Trivial constructor, interesting logic in the factory functions below. InlineCost(int Cost, int Threshold, int StaticBonusApplied, diff --git a/llvm/include/llvm/DWP/DWP.h b/llvm/include/llvm/DWP/DWP.h index ff26140..543354d 100644 --- a/llvm/include/llvm/DWP/DWP.h +++ b/llvm/include/llvm/DWP/DWP.h @@ -44,7 +44,7 @@ struct InfoSectionUnitHeader { // dwo_id field. This resides in the header only if Version >= 5. // In earlier versions, it is read from DW_AT_GNU_dwo_id. - std::optional Signature = std::nullopt; + std::optional Signature; // Derived from the length of Length field. dwarf::DwarfFormat Format = dwarf::DwarfFormat::DWARF32; diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index 1ba544d..3177cfe 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -3612,7 +3612,7 @@ public: /// their prof branch_weights metadata. class SwitchInstProfUpdateWrapper { SwitchInst &SI; - std::optional> Weights = std::nullopt; + std::optional> Weights; bool Changed = false; protected: diff --git a/llvm/include/llvm/LTO/Config.h b/llvm/include/llvm/LTO/Config.h index 2dbe284..4c79369 100644 --- a/llvm/include/llvm/LTO/Config.h +++ b/llvm/include/llvm/LTO/Config.h @@ -53,7 +53,7 @@ struct Config { /// For adding passes that run right before codegen. std::function PreCodeGenPassesHook; std::optional RelocModel = Reloc::PIC_; - std::optional CodeModel = std::nullopt; + std::optional CodeModel; CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default; CodeGenFileType CGFileType = CGFT_ObjectFile; unsigned OptLevel = 2; diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index ed2afc6..9f90ab2 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -120,7 +120,7 @@ template struct DataRegion { } const T *First; - std::optional Size = std::nullopt; + std::optional Size; const uint8_t *BufEnd = nullptr; }; diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index 2dd1c81..57365d2c 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -110,7 +110,7 @@ protected: // Can only create subclasses. unsigned O0WantsFastISel : 1; // PGO related tunables. - std::optional PGOOption = std::nullopt; + std::optional PGOOption; public: const TargetOptions DefaultOptions; diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h index 59a0d2a..1d813cb 100644 --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -1385,7 +1385,7 @@ struct AttributorConfig { DenseSet *Allowed = nullptr; /// Maximum number of iterations to run until fixpoint. - std::optional MaxFixpointIterations = std::nullopt; + std::optional MaxFixpointIterations; /// A callback function that returns an ORE object from a Function pointer. ///{ diff --git a/llvm/include/llvm/Transforms/Scalar/GVN.h b/llvm/include/llvm/Transforms/Scalar/GVN.h index 888a537..b043cfb 100644 --- a/llvm/include/llvm/Transforms/Scalar/GVN.h +++ b/llvm/include/llvm/Transforms/Scalar/GVN.h @@ -72,11 +72,11 @@ class GVNLegacyPass; /// Intended use is to create a default object, modify parameters with /// additional setters and then pass it to GVN. struct GVNOptions { - std::optional AllowPRE = std::nullopt; - std::optional AllowLoadPRE = std::nullopt; - std::optional AllowLoadInLoopPRE = std::nullopt; - std::optional AllowLoadPRESplitBackedge = std::nullopt; - std::optional AllowMemDep = std::nullopt; + std::optional AllowPRE; + std::optional AllowLoadPRE; + std::optional AllowLoadInLoopPRE; + std::optional AllowLoadPRESplitBackedge; + std::optional AllowMemDep; GVNOptions() = default; diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index e39940e..309da99 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -584,7 +584,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer { bool DecidedByCostBenefit = false; // The cost-benefit pair computed by cost-benefit analysis. - std::optional CostBenefit = std::nullopt; + std::optional CostBenefit; bool SingleBB = true; diff --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp index 0e6a122..fec7a0f 100644 --- a/llvm/lib/Analysis/MemorySSA.cpp +++ b/llvm/lib/Analysis/MemorySSA.cpp @@ -719,7 +719,7 @@ class ClobberWalker { T &curNode() const { return W->Paths[*N]; } Walker *W = nullptr; - std::optional N = std::nullopt; + std::optional N; }; using def_path_iterator = generic_def_path_iterator; diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 2a6f9b9..94e1ad2 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -1830,7 +1830,7 @@ void at::trackAssignments(Function::iterator Start, Function::iterator End, for (auto BBI = Start; BBI != End; ++BBI) { for (Instruction &I : *BBI) { - std::optional Info = std::nullopt; + std::optional Info; Value *ValueComponent = nullptr; Value *DestComponent = nullptr; if (auto *AI = dyn_cast(&I)) { diff --git a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp index 1859195..afea2b2 100644 --- a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp +++ b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp @@ -99,7 +99,7 @@ using LdStPairFlags = struct LdStPairFlags { // If not none, RenameReg can be used to rename the result register of the // first store in a pair. Currently this only works when merging stores // forward. - std::optional RenameReg = std::nullopt; + std::optional RenameReg; LdStPairFlags() = default; diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 48dcce7..5baa7e7 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -1697,7 +1697,7 @@ public: // Sometimes we have more than one option (e.g., Opcode and Undefs), so we // are using the score to differentiate between the two. struct BestOpData { - std::optional Idx = std::nullopt; + std::optional Idx; unsigned Score = 0; } BestOp; BestOp.Score = diff --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp index 1930ecd..8a5157f 100644 --- a/llvm/unittests/IR/DebugInfoTest.cpp +++ b/llvm/unittests/IR/DebugInfoTest.cpp @@ -198,8 +198,8 @@ TEST(DIBuiler, CreateFile) { DIFile *F = DIB.createFile("main.c", "/"); EXPECT_EQ(std::nullopt, F->getSource()); - std::optional> Checksum = std::nullopt; - std::optional Source = std::nullopt; + std::optional> Checksum; + std::optional Source; F = DIB.createFile("main.c", "/", Checksum, Source); EXPECT_EQ(Source, F->getSource()); diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp index 05f1cc1..926490f 100644 --- a/llvm/unittests/IR/MetadataTest.cpp +++ b/llvm/unittests/IR/MetadataTest.cpp @@ -2219,8 +2219,8 @@ TEST_F(DIFileTest, EmptySource) { DIFile *N = DIFile::get(Context, "file", "dir"); EXPECT_EQ(std::nullopt, N->getSource()); - std::optional> Checksum = std::nullopt; - std::optional Source = std::nullopt; + std::optional> Checksum; + std::optional Source; N = DIFile::get(Context, "file", "dir", Checksum, Source); EXPECT_EQ(Source, N->getSource()); -- 2.7.4