From 3b7c3a654c9175f41ac871a937cbcae73dfb3c5d Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 25 Jun 2022 11:56:50 -0700 Subject: Revert "Don't use Optional::hasValue (NFC)" This reverts commit aa8feeefd3ac6c78ee8f67bf033976fc7d68bc6d. --- polly/lib/Exchange/JSONExporter.cpp | 23 ++++++++++++----------- polly/lib/Transform/ManualOptimizer.cpp | 4 ++-- polly/lib/Transform/MatmulOptimizer.cpp | 16 ++++++++-------- 3 files changed, 22 insertions(+), 21 deletions(-) (limited to 'polly') diff --git a/polly/lib/Exchange/JSONExporter.cpp b/polly/lib/Exchange/JSONExporter.cpp index d882ea6..e92055b 100644 --- a/polly/lib/Exchange/JSONExporter.cpp +++ b/polly/lib/Exchange/JSONExporter.cpp @@ -218,8 +218,8 @@ static bool importContext(Scop &S, const json::Object &JScop) { return false; } - isl::set NewContext = - isl::set{S.getIslCtx().get(), JScop.getString("context")->str()}; + isl::set NewContext = isl::set{S.getIslCtx().get(), + JScop.getString("context").getValue().str()}; // Check whether the context was parsed successfully. if (NewContext.is_null()) { @@ -290,10 +290,10 @@ static bool importSchedule(Scop &S, const json::Object &JScop, } Optional Schedule = statements[Index].getAsObject()->getString("schedule"); - assert(Schedule && + assert(Schedule.hasValue() && "Schedules that contain extension nodes require special handling."); - isl_map *Map = - isl_map_read_from_str(S.getIslCtx().get(), Schedule->str().c_str()); + isl_map *Map = isl_map_read_from_str(S.getIslCtx().get(), + Schedule.getValue().str().c_str()); // Check whether the schedule was parsed successfully if (!Map) { @@ -575,14 +575,14 @@ static bool areArraysEqual(ScopArrayInfo *SAI, const json::Object &Array) { for (unsigned i = 1; i < Array.getArray("sizes")->size(); i++) { SAI->getDimensionSize(i)->print(RawStringOstream); const json::Array &SizesArray = *Array.getArray("sizes"); - if (RawStringOstream.str() != SizesArray[i].getAsString().value()) + if (RawStringOstream.str() != SizesArray[i].getAsString().getValue()) return false; Buffer.clear(); } // Check if key 'type' differs from the current one or is not valid. SAI->getElementType()->print(RawStringOstream); - if (RawStringOstream.str() != Array.getString("type").value()) { + if (RawStringOstream.str() != Array.getString("type").getValue()) { errs() << "Array has not a valid type.\n"; return false; } @@ -652,8 +652,9 @@ static bool importArrays(Scop &S, const json::Object &JScop) { for (; ArrayIdx < Arrays.size(); ArrayIdx++) { const json::Object &Array = *Arrays[ArrayIdx].getAsObject(); - auto *ElementType = parseTextType(Array.get("type")->getAsString()->str(), - S.getSE()->getContext()); + auto *ElementType = + parseTextType(Array.get("type")->getAsString().getValue().str(), + S.getSE()->getContext()); if (!ElementType) { errs() << "Error while parsing element type for new array.\n"; return false; @@ -673,10 +674,10 @@ static bool importArrays(Scop &S, const json::Object &JScop) { } auto NewSAI = S.createScopArrayInfo( - ElementType, Array.getString("name")->str(), DimSizes); + ElementType, Array.getString("name").getValue().str(), DimSizes); if (Array.get("allocation")) { - NewSAI->setIsOnHeap(Array.getString("allocation").value() == "heap"); + NewSAI->setIsOnHeap(Array.getString("allocation").getValue() == "heap"); } } diff --git a/polly/lib/Transform/ManualOptimizer.cpp b/polly/lib/Transform/ManualOptimizer.cpp index 21d83d9..ef705ec 100644 --- a/polly/lib/Transform/ManualOptimizer.cpp +++ b/polly/lib/Transform/ManualOptimizer.cpp @@ -42,8 +42,8 @@ static TransformationMode hasUnrollTransformation(MDNode *LoopID) { Optional Count = getOptionalIntLoopAttribute(LoopID, "llvm.loop.unroll.count"); - if (Count) - return *Count == 1 ? TM_SuppressedByUser : TM_ForcedByUser; + if (Count.hasValue()) + return Count.getValue() == 1 ? TM_SuppressedByUser : TM_ForcedByUser; if (getBooleanLoopAttribute(LoopID, "llvm.loop.unroll.enable")) return TM_ForcedByUser; diff --git a/polly/lib/Transform/MatmulOptimizer.cpp b/polly/lib/Transform/MatmulOptimizer.cpp index d7418d3..4a40fac 100644 --- a/polly/lib/Transform/MatmulOptimizer.cpp +++ b/polly/lib/Transform/MatmulOptimizer.cpp @@ -570,29 +570,29 @@ static void getTargetCacheParameters(const llvm::TargetTransformInfo *TTI) { auto L1DCache = llvm::TargetTransformInfo::CacheLevel::L1D; auto L2DCache = llvm::TargetTransformInfo::CacheLevel::L2D; if (FirstCacheLevelSize == -1) { - if (TTI->getCacheSize(L1DCache).has_value()) - FirstCacheLevelSize = TTI->getCacheSize(L1DCache).value(); + if (TTI->getCacheSize(L1DCache).hasValue()) + FirstCacheLevelSize = TTI->getCacheSize(L1DCache).getValue(); else FirstCacheLevelSize = static_cast(FirstCacheLevelDefaultSize); } if (SecondCacheLevelSize == -1) { - if (TTI->getCacheSize(L2DCache).has_value()) - SecondCacheLevelSize = TTI->getCacheSize(L2DCache).value(); + if (TTI->getCacheSize(L2DCache).hasValue()) + SecondCacheLevelSize = TTI->getCacheSize(L2DCache).getValue(); else SecondCacheLevelSize = static_cast(SecondCacheLevelDefaultSize); } if (FirstCacheLevelAssociativity == -1) { - if (TTI->getCacheAssociativity(L1DCache).has_value()) + if (TTI->getCacheAssociativity(L1DCache).hasValue()) FirstCacheLevelAssociativity = - TTI->getCacheAssociativity(L1DCache).value(); + TTI->getCacheAssociativity(L1DCache).getValue(); else FirstCacheLevelAssociativity = static_cast(FirstCacheLevelDefaultAssociativity); } if (SecondCacheLevelAssociativity == -1) { - if (TTI->getCacheAssociativity(L2DCache).has_value()) + if (TTI->getCacheAssociativity(L2DCache).hasValue()) SecondCacheLevelAssociativity = - TTI->getCacheAssociativity(L2DCache).value(); + TTI->getCacheAssociativity(L2DCache).getValue(); else SecondCacheLevelAssociativity = static_cast(SecondCacheLevelDefaultAssociativity); -- cgit v1.1