-
Notifications
You must be signed in to change notification settings - Fork 14k
[nfc][jt] Drop std::optional
pointers
#144548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mtrofin
wants to merge
1
commit into
main
Choose a base branch
from
users/mtrofin/06-17-_nfc_jt_drop_std_optional_pointer_
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[nfc][jt] Drop std::optional
pointers
#144548
mtrofin
wants to merge
1
commit into
main
from
users/mtrofin/06-17-_nfc_jt_drop_std_optional_pointer_
+10
−11
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::optional
pointers
@llvm/pr-subscribers-llvm-transforms Author: Mircea Trofin (mtrofin) ChangesThe Full diff: https://github.com/llvm/llvm-project/pull/144548.diff 2 Files Affected:
diff --git a/llvm/include/llvm/Transforms/Scalar/JumpThreading.h b/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
index 75b5cf2371fda..a03a38466b27b 100644
--- a/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
+++ b/llvm/include/llvm/Transforms/Scalar/JumpThreading.h
@@ -85,8 +85,8 @@ class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
LazyValueInfo *LVI = nullptr;
AAResults *AA = nullptr;
std::unique_ptr<DomTreeUpdater> DTU;
- std::optional<BlockFrequencyInfo *> BFI;
- std::optional<BranchProbabilityInfo *> BPI;
+ BlockFrequencyInfo *BFI = nullptr;
+ BranchProbabilityInfo *BPI = nullptr;
bool ChangedSinceLastAnalysisUpdate = false;
bool HasGuards = false;
#ifndef LLVM_ENABLE_ABI_BREAKING_CHECKS
@@ -110,8 +110,7 @@ class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
TargetLibraryInfo *TLI, TargetTransformInfo *TTI,
LazyValueInfo *LVI, AAResults *AA,
std::unique_ptr<DomTreeUpdater> DTU,
- std::optional<BlockFrequencyInfo *> BFI,
- std::optional<BranchProbabilityInfo *> BPI);
+ BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI);
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index 37b85bf9de811..b5dbef13289ac 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -249,7 +249,7 @@ PreservedAnalyses JumpThreadingPass::run(Function &F,
runImpl(F, &AM, &TLI, &TTI, &LVI, &AA,
std::make_unique<DomTreeUpdater>(
&DT, nullptr, DomTreeUpdater::UpdateStrategy::Lazy),
- std::nullopt, std::nullopt);
+ nullptr, nullptr);
if (!Changed)
return PreservedAnalyses::all();
@@ -283,8 +283,8 @@ bool JumpThreadingPass::runImpl(Function &F_, FunctionAnalysisManager *FAM_,
TargetTransformInfo *TTI_, LazyValueInfo *LVI_,
AliasAnalysis *AA_,
std::unique_ptr<DomTreeUpdater> DTU_,
- std::optional<BlockFrequencyInfo *> BFI_,
- std::optional<BranchProbabilityInfo *> BPI_) {
+ BlockFrequencyInfo *BFI_,
+ BranchProbabilityInfo *BPI_) {
LLVM_DEBUG(dbgs() << "Jump threading on function '" << F_.getName() << "'\n");
F = &F_;
FAM = FAM_;
@@ -3215,7 +3215,7 @@ BranchProbabilityInfo *JumpThreadingPass::getBPI() {
assert(FAM && "Can't create BPI without FunctionAnalysisManager");
BPI = FAM->getCachedResult<BranchProbabilityAnalysis>(*F);
}
- return *BPI;
+ return BPI;
}
BlockFrequencyInfo *JumpThreadingPass::getBFI() {
@@ -3223,7 +3223,7 @@ BlockFrequencyInfo *JumpThreadingPass::getBFI() {
assert(FAM && "Can't create BFI without FunctionAnalysisManager");
BFI = FAM->getCachedResult<BlockFrequencyAnalysis>(*F);
}
- return *BFI;
+ return BFI;
}
// Important note on validity of BPI/BFI. JumpThreading tries to preserve
@@ -3237,7 +3237,7 @@ BranchProbabilityInfo *JumpThreadingPass::getOrCreateBPI(bool Force) {
if (Force)
BPI = runExternalAnalysis<BranchProbabilityAnalysis>();
- return *BPI;
+ return BPI;
}
BlockFrequencyInfo *JumpThreadingPass::getOrCreateBFI(bool Force) {
@@ -3248,5 +3248,5 @@ BlockFrequencyInfo *JumpThreadingPass::getOrCreateBFI(bool Force) {
if (Force)
BFI = runExternalAnalysis<BlockFrequencyAnalysis>();
- return *BFI;
+ return BFI;
}
|
kazutakahirata
approved these changes
Jun 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
91486bd
to
dfea4c6
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
std::optional
didn't add any semantics that couldn't be modeled with the pointers beingnullptr
.