[llvm] c08fad8 - [llvm] Remove redundant initialization of std::optional (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 20 15:53:45 PST 2022
Author: Kazu Hirata
Date: 2022-12-20T15:53:38-08:00
New Revision: c08fad8193d3a8387f3ddd895b850b8afec928af
URL: https://github.com/llvm/llvm-project/commit/c08fad8193d3a8387f3ddd895b850b8afec928af
DIFF: https://github.com/llvm/llvm-project/commit/c08fad8193d3a8387f3ddd895b850b8afec928af.diff
LOG: [llvm] Remove redundant initialization of std::optional (NFC)
Added:
Modified:
llvm/include/llvm/Analysis/InlineCost.h
llvm/include/llvm/DWP/DWP.h
llvm/include/llvm/IR/Instructions.h
llvm/include/llvm/LTO/Config.h
llvm/include/llvm/Object/ELF.h
llvm/include/llvm/Target/TargetMachine.h
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/include/llvm/Transforms/Scalar/GVN.h
llvm/lib/Analysis/InlineCost.cpp
llvm/lib/Analysis/MemorySSA.cpp
llvm/lib/IR/DebugInfo.cpp
llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/unittests/IR/DebugInfoTest.cpp
llvm/unittests/IR/MetadataTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/InlineCost.h b/llvm/include/llvm/Analysis/InlineCost.h
index 7e567895215a1..57f452853d2d6 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<CostBenefitPair> CostBenefit = std::nullopt;
+ std::optional<CostBenefitPair> 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 ff2614000fe10..543354d86bbb5 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<uint64_t> Signature = std::nullopt;
+ std::optional<uint64_t> 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 1ba544dd5143a..3177cfe0a6a01 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -3612,7 +3612,7 @@ class SwitchInst : public Instruction {
/// their prof branch_weights metadata.
class SwitchInstProfUpdateWrapper {
SwitchInst &SI;
- std::optional<SmallVector<uint32_t, 8>> Weights = std::nullopt;
+ std::optional<SmallVector<uint32_t, 8>> Weights;
bool Changed = false;
protected:
diff --git a/llvm/include/llvm/LTO/Config.h b/llvm/include/llvm/LTO/Config.h
index 2dbe284ff449b..4c793697da022 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<void(legacy::PassManager &)> PreCodeGenPassesHook;
std::optional<Reloc::Model> RelocModel = Reloc::PIC_;
- std::optional<CodeModel::Model> CodeModel = std::nullopt;
+ std::optional<CodeModel::Model> 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 ed2afc6042245..9f90ab2e702aa 100644
--- a/llvm/include/llvm/Object/ELF.h
+++ b/llvm/include/llvm/Object/ELF.h
@@ -120,7 +120,7 @@ template <class T> struct DataRegion {
}
const T *First;
- std::optional<uint64_t> Size = std::nullopt;
+ std::optional<uint64_t> Size;
const uint8_t *BufEnd = nullptr;
};
diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
index 2dd1c81995130..57365d2c74d69 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -110,7 +110,7 @@ class TargetMachine {
unsigned O0WantsFastISel : 1;
// PGO related tunables.
- std::optional<PGOOptions> PGOOption = std::nullopt;
+ std::optional<PGOOptions> PGOOption;
public:
const TargetOptions DefaultOptions;
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 59a0d2ae6f882..1d813cb8b3385 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1385,7 +1385,7 @@ struct AttributorConfig {
DenseSet<const char *> *Allowed = nullptr;
/// Maximum number of iterations to run until fixpoint.
- std::optional<unsigned> MaxFixpointIterations = std::nullopt;
+ std::optional<unsigned> 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 888a537ba2596..b043cfb2c258c 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<bool> AllowPRE = std::nullopt;
- std::optional<bool> AllowLoadPRE = std::nullopt;
- std::optional<bool> AllowLoadInLoopPRE = std::nullopt;
- std::optional<bool> AllowLoadPRESplitBackedge = std::nullopt;
- std::optional<bool> AllowMemDep = std::nullopt;
+ std::optional<bool> AllowPRE;
+ std::optional<bool> AllowLoadPRE;
+ std::optional<bool> AllowLoadInLoopPRE;
+ std::optional<bool> AllowLoadPRESplitBackedge;
+ std::optional<bool> AllowMemDep;
GVNOptions() = default;
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index e39940ed6a9b5..309da995e5f3b 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<CostBenefitPair> CostBenefit = std::nullopt;
+ std::optional<CostBenefitPair> CostBenefit;
bool SingleBB = true;
diff --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp
index 0e6a12261e23a..fec7a0fd35795 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<ListIndex> N = std::nullopt;
+ std::optional<ListIndex> N;
};
using def_path_iterator = generic_def_path_iterator<DefPath, ClobberWalker>;
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 2a6f9b9673a36..94e1ad211eeab 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<AssignmentInfo> Info = std::nullopt;
+ std::optional<AssignmentInfo> Info;
Value *ValueComponent = nullptr;
Value *DestComponent = nullptr;
if (auto *AI = dyn_cast<AllocaInst>(&I)) {
diff --git a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
index 1859195de86ef..afea2b2f5f754 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<MCPhysReg> RenameReg = std::nullopt;
+ std::optional<MCPhysReg> RenameReg;
LdStPairFlags() = default;
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 48dcce72ee45c..5baa7e78a58f6 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -1697,7 +1697,7 @@ class BoUpSLP {
// Sometimes we have more than one option (e.g., Opcode and Undefs), so we
// are using the score to
diff erentiate between the two.
struct BestOpData {
- std::optional<unsigned> Idx = std::nullopt;
+ std::optional<unsigned> Idx;
unsigned Score = 0;
} BestOp;
BestOp.Score =
diff --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp
index 1930ecdd8cc9f..8a5157f292bbb 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<DIFile::ChecksumInfo<StringRef>> Checksum = std::nullopt;
- std::optional<StringRef> Source = std::nullopt;
+ std::optional<DIFile::ChecksumInfo<StringRef>> Checksum;
+ std::optional<StringRef> 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 05f1cc17dfdf3..926490f6b0b05 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<DIFile::ChecksumInfo<StringRef>> Checksum = std::nullopt;
- std::optional<StringRef> Source = std::nullopt;
+ std::optional<DIFile::ChecksumInfo<StringRef>> Checksum;
+ std::optional<StringRef> Source;
N = DIFile::get(Context, "file", "dir", Checksum, Source);
EXPECT_EQ(Source, N->getSource());
More information about the llvm-commits
mailing list