Skip to content

Commit bdac958

Browse files
authored
[nfc][jt] Drop std::optional pointers (#144548)
The `std::optional` didn't add any semantics that couldn't be modeled with the pointers being `nullptr`.
1 parent fda6b75 commit bdac958

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

llvm/include/llvm/Transforms/Scalar/JumpThreading.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
8585
LazyValueInfo *LVI = nullptr;
8686
AAResults *AA = nullptr;
8787
std::unique_ptr<DomTreeUpdater> DTU;
88-
std::optional<BlockFrequencyInfo *> BFI;
89-
std::optional<BranchProbabilityInfo *> BPI;
88+
BlockFrequencyInfo *BFI = nullptr;
89+
BranchProbabilityInfo *BPI = nullptr;
9090
bool ChangedSinceLastAnalysisUpdate = false;
9191
bool HasGuards = false;
9292
#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
@@ -110,8 +110,7 @@ class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
110110
TargetLibraryInfo *TLI, TargetTransformInfo *TTI,
111111
LazyValueInfo *LVI, AAResults *AA,
112112
std::unique_ptr<DomTreeUpdater> DTU,
113-
std::optional<BlockFrequencyInfo *> BFI,
114-
std::optional<BranchProbabilityInfo *> BPI);
113+
BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI);
115114

116115
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
117116

llvm/lib/Transforms/Scalar/JumpThreading.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ PreservedAnalyses JumpThreadingPass::run(Function &F,
249249
runImpl(F, &AM, &TLI, &TTI, &LVI, &AA,
250250
std::make_unique<DomTreeUpdater>(
251251
&DT, nullptr, DomTreeUpdater::UpdateStrategy::Lazy),
252-
std::nullopt, std::nullopt);
252+
nullptr, nullptr);
253253

254254
if (!Changed)
255255
return PreservedAnalyses::all();
@@ -283,8 +283,8 @@ bool JumpThreadingPass::runImpl(Function &F_, FunctionAnalysisManager *FAM_,
283283
TargetTransformInfo *TTI_, LazyValueInfo *LVI_,
284284
AliasAnalysis *AA_,
285285
std::unique_ptr<DomTreeUpdater> DTU_,
286-
std::optional<BlockFrequencyInfo *> BFI_,
287-
std::optional<BranchProbabilityInfo *> BPI_) {
286+
BlockFrequencyInfo *BFI_,
287+
BranchProbabilityInfo *BPI_) {
288288
LLVM_DEBUG(dbgs() << "Jump threading on function '" << F_.getName() << "'\n");
289289
F = &F_;
290290
FAM = FAM_;
@@ -3215,15 +3215,15 @@ BranchProbabilityInfo *JumpThreadingPass::getBPI() {
32153215
assert(FAM && "Can't create BPI without FunctionAnalysisManager");
32163216
BPI = FAM->getCachedResult<BranchProbabilityAnalysis>(*F);
32173217
}
3218-
return *BPI;
3218+
return BPI;
32193219
}
32203220

32213221
BlockFrequencyInfo *JumpThreadingPass::getBFI() {
32223222
if (!BFI) {
32233223
assert(FAM && "Can't create BFI without FunctionAnalysisManager");
32243224
BFI = FAM->getCachedResult<BlockFrequencyAnalysis>(*F);
32253225
}
3226-
return *BFI;
3226+
return BFI;
32273227
}
32283228

32293229
// Important note on validity of BPI/BFI. JumpThreading tries to preserve
@@ -3237,7 +3237,7 @@ BranchProbabilityInfo *JumpThreadingPass::getOrCreateBPI(bool Force) {
32373237
if (Force)
32383238
BPI = runExternalAnalysis<BranchProbabilityAnalysis>();
32393239

3240-
return *BPI;
3240+
return BPI;
32413241
}
32423242

32433243
BlockFrequencyInfo *JumpThreadingPass::getOrCreateBFI(bool Force) {
@@ -3248,5 +3248,5 @@ BlockFrequencyInfo *JumpThreadingPass::getOrCreateBFI(bool Force) {
32483248
if (Force)
32493249
BFI = runExternalAnalysis<BlockFrequencyAnalysis>();
32503250

3251-
return *BFI;
3251+
return BFI;
32523252
}

0 commit comments

Comments
 (0)