[llvm] d90a14f - [Scalar] Use std::optional in SimpleLoopUnswitch.cpp (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 26 17:41:57 PST 2022


Author: Kazu Hirata
Date: 2022-11-26T17:41:52-08:00
New Revision: d90a14f87d24119bde7b0cd18f2afa089c78b27e

URL: https://github.com/llvm/llvm-project/commit/d90a14f87d24119bde7b0cd18f2afa089c78b27e
DIFF: https://github.com/llvm/llvm-project/commit/d90a14f87d24119bde7b0cd18f2afa089c78b27e.diff

LOG: [Scalar] Use std::optional in SimpleLoopUnswitch.cpp (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index 74e6adf7de82..35494e86996b 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -63,6 +63,7 @@
 #include <cassert>
 #include <iterator>
 #include <numeric>
+#include <optional>
 #include <utility>
 
 #define DEBUG_TYPE "simple-loop-unswitch"
@@ -2988,7 +2989,7 @@ static NonTrivialUnswitchCandidate findBestNonTrivialUnswitchCandidate(
     return (LoopCost - Cost) * (SuccessorsCount - 1);
   };
 
-  Optional<NonTrivialUnswitchCandidate> Best;
+  std::optional<NonTrivialUnswitchCandidate> Best;
   for (auto &Candidate : UnswitchCandidates) {
     Instruction &TI = *Candidate.TI;
     ArrayRef<Value *> Invariants = Candidate.Invariants;
@@ -3210,7 +3211,7 @@ PreservedAnalyses SimpleLoopUnswitchPass::run(Loop &L, LoopAnalysisManager &AM,
     U.markLoopAsDeleted(L, Name);
   };
 
-  Optional<MemorySSAUpdater> MSSAU;
+  std::optional<MemorySSAUpdater> MSSAU;
   if (AR.MSSA) {
     MSSAU = MemorySSAUpdater(AR.MSSA);
     if (VerifyMemorySSA)


        


More information about the llvm-commits mailing list