[polly] Use std::optional instead of llvm::Optional (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
This commit is contained in:
Kazu Hirata 2023-01-02 19:18:46 -08:00
parent 1ae689109f
commit ccdc271a08
6 changed files with 22 additions and 18 deletions

View File

@ -34,6 +34,7 @@
#include <cassert>
#include <cstddef>
#include <forward_list>
#include <optional>
namespace polly {
using llvm::AnalysisInfoMixin;
@ -51,7 +52,6 @@ using llvm::LoadInst;
using llvm::make_range;
using llvm::MapVector;
using llvm::MemIntrinsic;
using llvm::Optional;
using llvm::PassInfoMixin;
using llvm::PHINode;
using llvm::RegionNode;
@ -1662,7 +1662,7 @@ private:
Region &R;
/// The name of the SCoP (identical to the regions name)
Optional<std::string> name;
std::optional<std::string> name;
// Access functions of the SCoP.
//

View File

@ -18,6 +18,7 @@
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/ValueHandle.h"
#include "isl/isl-noexceptions.h"
#include <optional>
namespace llvm {
class LoopInfo;
@ -522,16 +523,16 @@ bool hasDebugCall(ScopStmt *Stmt);
///
/// Then `nullptr` is set to mark the property is existing, but does not carry
/// any value. If the property does not exist, `None` is returned.
llvm::Optional<llvm::Metadata *> findMetadataOperand(llvm::MDNode *LoopMD,
llvm::StringRef Name);
std::optional<llvm::Metadata *> findMetadataOperand(llvm::MDNode *LoopMD,
llvm::StringRef Name);
/// Find a boolean property value in a LoopID. The value not being defined is
/// interpreted as a false value.
bool getBooleanLoopAttribute(llvm::MDNode *LoopID, llvm::StringRef Name);
/// Find an integers property value in a LoopID.
llvm::Optional<int> getOptionalIntLoopAttribute(llvm::MDNode *LoopID,
llvm::StringRef Name);
std::optional<int> getOptionalIntLoopAttribute(llvm::MDNode *LoopID,
llvm::StringRef Name);
/// Does the loop's LoopID contain a 'llvm.loop.disable_heuristics' property?
///

View File

@ -19,6 +19,7 @@
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include <optional>
using namespace llvm;
using namespace polly;
@ -119,7 +120,7 @@ bool ScopAnalysisManagerFunctionProxy::Result::invalidate(
// Even if all analyses were preserved, we still need to run deferred
// invalidation
for (auto &S : *SI) {
Optional<PreservedAnalyses> InnerPA;
std::optional<PreservedAnalyses> InnerPA;
auto *scop = S.second.get();
if (!scop)
continue;

View File

@ -21,6 +21,7 @@
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
#include <optional>
using namespace llvm;
using namespace polly;
@ -699,8 +700,8 @@ static MDNode *findNamedMetadataNode(MDNode *LoopMD, StringRef Name) {
return nullptr;
}
static Optional<const MDOperand *> findNamedMetadataArg(MDNode *LoopID,
StringRef Name) {
static std::optional<const MDOperand *> findNamedMetadataArg(MDNode *LoopID,
StringRef Name) {
MDNode *MD = findNamedMetadataNode(LoopID, Name);
if (!MD)
return std::nullopt;
@ -714,8 +715,8 @@ static Optional<const MDOperand *> findNamedMetadataArg(MDNode *LoopID,
}
}
Optional<Metadata *> polly::findMetadataOperand(MDNode *LoopMD,
StringRef Name) {
std::optional<Metadata *> polly::findMetadataOperand(MDNode *LoopMD,
StringRef Name) {
MDNode *MD = findNamedMetadataNode(LoopMD, Name);
if (!MD)
return std::nullopt;
@ -729,8 +730,8 @@ Optional<Metadata *> polly::findMetadataOperand(MDNode *LoopMD,
}
}
static Optional<bool> getOptionalBoolLoopAttribute(MDNode *LoopID,
StringRef Name) {
static std::optional<bool> getOptionalBoolLoopAttribute(MDNode *LoopID,
StringRef Name) {
MDNode *MD = findNamedMetadataNode(LoopID, Name);
if (!MD)
return std::nullopt;
@ -750,8 +751,8 @@ bool polly::getBooleanLoopAttribute(MDNode *LoopID, StringRef Name) {
return getOptionalBoolLoopAttribute(LoopID, Name).value_or(false);
}
llvm::Optional<int> polly::getOptionalIntLoopAttribute(MDNode *LoopID,
StringRef Name) {
std::optional<int> polly::getOptionalIntLoopAttribute(MDNode *LoopID,
StringRef Name) {
const MDOperand *AttrMD =
findNamedMetadataArg(LoopID, Name).value_or(nullptr);
if (!AttrMD)

View File

@ -15,12 +15,12 @@
#include "polly/Options.h"
#include "polly/ScheduleTreeTransform.h"
#include "polly/Support/ScopHelper.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
#include "llvm/IR/Metadata.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include <optional>
#define DEBUG_TYPE "polly-opt-manual"
@ -40,7 +40,7 @@ static TransformationMode hasUnrollTransformation(MDNode *LoopID) {
if (getBooleanLoopAttribute(LoopID, "llvm.loop.unroll.disable"))
return TM_SuppressedByUser;
Optional<int> Count =
std::optional<int> Count =
getOptionalIntLoopAttribute(LoopID, "llvm.loop.unroll.count");
if (Count)
return *Count == 1 ? TM_SuppressedByUser : TM_ForcedByUser;

View File

@ -20,6 +20,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/Debug.h"
#include <optional>
#define DEBUG_TYPE "polly-simplify"
@ -758,7 +759,7 @@ class SimplifyWrapperPass final : public ScopPass {
public:
static char ID;
int CallNo;
Optional<SimplifyImpl> Impl;
std::optional<SimplifyImpl> Impl;
explicit SimplifyWrapperPass(int CallNo = 0) : ScopPass(ID), CallNo(CallNo) {}