aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUtils.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2022-12-12 08:29:05 +0000
committerFangrui Song <i@maskray.me>2022-12-12 08:29:05 +0000
commitc178ed33bd82151f21abc3c0015c671b33556999 (patch)
tree49ff57aa48c95a6edf0c97e1084a998205f4faf4 /llvm/lib/Transforms/Utils/LoopUtils.cpp
parenta73455ac8e9bd02f843916c12c261cfd9ccb06a9 (diff)
downloadllvm-c178ed33bd82151f21abc3c0015c671b33556999.zip
llvm-c178ed33bd82151f21abc3c0015c671b33556999.tar.gz
llvm-c178ed33bd82151f21abc3c0015c671b33556999.tar.bz2
Transforms/Utils: llvm::Optional => std::optional
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUtils.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index 9ada3a2d..0e4576f 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -247,7 +247,7 @@ void llvm::addStringMetadataToLoop(Loop *TheLoop, const char *StringMD,
TheLoop->setLoopID(NewLoopID);
}
-Optional<ElementCount>
+std::optional<ElementCount>
llvm::getOptionalElementCountLoopAttribute(const Loop *TheLoop) {
std::optional<int> Width =
getOptionalIntLoopAttribute(TheLoop, "llvm.loop.vectorize.width");
@@ -261,7 +261,7 @@ llvm::getOptionalElementCountLoopAttribute(const Loop *TheLoop) {
return std::nullopt;
}
-Optional<MDNode *> llvm::makeFollowupLoopID(
+std::optional<MDNode *> llvm::makeFollowupLoopID(
MDNode *OrigLoopID, ArrayRef<StringRef> FollowupOptions,
const char *InheritOptionsExceptPrefix, bool AlwaysNew) {
if (!OrigLoopID) {
@@ -396,7 +396,7 @@ TransformationMode llvm::hasVectorizeTransformation(const Loop *L) {
if (Enable == false)
return TM_SuppressedByUser;
- Optional<ElementCount> VectorizeWidth =
+ std::optional<ElementCount> VectorizeWidth =
getOptionalElementCountLoopAttribute(L);
std::optional<int> InterleaveCount =
getOptionalIntLoopAttribute(L, "llvm.loop.interleave.count");
@@ -782,9 +782,9 @@ static BranchInst *getExpectedExitLoopLatchBranch(Loop *L) {
/// Return the estimated trip count for any exiting branch which dominates
/// the loop latch.
-static Optional<uint64_t>
-getEstimatedTripCount(BranchInst *ExitingBranch, Loop *L,
- uint64_t &OrigExitWeight) {
+static std::optional<uint64_t> getEstimatedTripCount(BranchInst *ExitingBranch,
+ Loop *L,
+ uint64_t &OrigExitWeight) {
// To estimate the number of times the loop body was executed, we want to
// know the number of times the backedge was taken, vs. the number of times
// we exited the loop.
@@ -808,7 +808,7 @@ getEstimatedTripCount(BranchInst *ExitingBranch, Loop *L,
return ExitCount + 1;
}
-Optional<unsigned>
+std::optional<unsigned>
llvm::getLoopEstimatedTripCount(Loop *L,
unsigned *EstimatedLoopInvocationWeight) {
// Currently we take the estimate exit count only from the loop latch,
@@ -817,8 +817,8 @@ llvm::getLoopEstimatedTripCount(Loop *L,
// TODO: incorporate information from other exits
if (BranchInst *LatchBranch = getExpectedExitLoopLatchBranch(L)) {
uint64_t ExitWeight;
- if (Optional<uint64_t> EstTripCount =
- getEstimatedTripCount(LatchBranch, L, ExitWeight)) {
+ if (std::optional<uint64_t> EstTripCount =
+ getEstimatedTripCount(LatchBranch, L, ExitWeight)) {
if (EstimatedLoopInvocationWeight)
*EstimatedLoopInvocationWeight = ExitWeight;
return *EstTripCount;
@@ -1477,7 +1477,7 @@ void llvm::setProfileInfoAfterUnrolling(Loop *OrigLoop, Loop *UnrolledLoop,
// Get number of iterations in the original scalar loop.
unsigned OrigLoopInvocationWeight = 0;
- Optional<unsigned> OrigAverageTripCount =
+ std::optional<unsigned> OrigAverageTripCount =
getLoopEstimatedTripCount(OrigLoop, &OrigLoopInvocationWeight);
if (!OrigAverageTripCount)
return;
@@ -1704,10 +1704,9 @@ Value *llvm::addDiffRuntimeChecks(
return MemoryRuntimeCheck;
}
-Optional<IVConditionInfo> llvm::hasPartialIVCondition(const Loop &L,
- unsigned MSSAThreshold,
- const MemorySSA &MSSA,
- AAResults &AA) {
+std::optional<IVConditionInfo>
+llvm::hasPartialIVCondition(const Loop &L, unsigned MSSAThreshold,
+ const MemorySSA &MSSA, AAResults &AA) {
auto *TI = dyn_cast<BranchInst>(L.getHeader()->getTerminator());
if (!TI || !TI->isConditional())
return {};
@@ -1764,7 +1763,7 @@ Optional<IVConditionInfo> llvm::hasPartialIVCondition(const Loop &L,
[&L, &AA, &AccessedLocs, &ExitingBlocks, &InstToDuplicate,
MSSAThreshold](BasicBlock *Succ, BasicBlock *Header,
SmallVector<MemoryAccess *, 4> AccessesToCheck)
- -> Optional<IVConditionInfo> {
+ -> std::optional<IVConditionInfo> {
IVConditionInfo Info;
// First, collect all blocks in the loop that are on a patch from Succ
// to the header.