[llvm] 7de7c40 - [MemLoc] Use hasValue() method (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 19 12:55:12 PST 2020


Author: Nikita Popov
Date: 2020-11-19T21:53:50+01:00
New Revision: 7de7c40898a8f815d661781c92757f93fa4c6e5b

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

LOG: [MemLoc] Use hasValue() method (NFC)

Instead of comparing to LocationSize::unknown(), prefer calling
the hasValue() method instead, which is less reliant on
implementation details.

Added: 
    

Modified: 
    llvm/lib/Analysis/BasicAliasAnalysis.cpp
    llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 2095702e8ae8..b73e1cfe56e0 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1050,8 +1050,7 @@ static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,
 
   // If we don't know the size of the accesses through both GEPs, we can't
   // determine whether the struct fields accessed can't alias.
-  if (MaybeV1Size == LocationSize::unknown() ||
-      MaybeV2Size == LocationSize::unknown())
+  if (!MaybeV1Size.hasValue() || !MaybeV2Size.hasValue())
     return MayAlias;
 
   const uint64_t V1Size = MaybeV1Size.getValue();
@@ -1185,7 +1184,7 @@ bool BasicAAResult::isGEPBaseAtNegativeOffset(const GEPOperator *GEPOp,
       const DecomposedGEP &DecompGEP, const DecomposedGEP &DecompObject,
       LocationSize MaybeObjectAccessSize) {
   // If the object access size is unknown, or the GEP isn't inbounds, bail.
-  if (MaybeObjectAccessSize == LocationSize::unknown() || !GEPOp->isInBounds())
+  if (!MaybeObjectAccessSize.hasValue() || !GEPOp->isInBounds())
     return false;
 
   const uint64_t ObjectAccessSize = MaybeObjectAccessSize.getValue();
@@ -1302,7 +1301,7 @@ AliasResult BasicAAResult::aliasGEP(
     // pointer, we know they cannot alias.
 
     // If both accesses are unknown size, we can't do anything useful here.
-    if (V1Size == LocationSize::unknown() && V2Size == LocationSize::unknown())
+    if (!V1Size.hasValue() && !V2Size.hasValue())
       return MayAlias;
 
     AliasResult R = aliasCheck(UnderlyingV1, LocationSize::unknown(),
@@ -1877,8 +1876,8 @@ bool BasicAAResult::constantOffsetHeuristic(
     const SmallVectorImpl<VariableGEPIndex> &VarIndices,
     LocationSize MaybeV1Size, LocationSize MaybeV2Size, const APInt &BaseOffset,
     AssumptionCache *AC, DominatorTree *DT) {
-  if (VarIndices.size() != 2 || MaybeV1Size == LocationSize::unknown() ||
-      MaybeV2Size == LocationSize::unknown())
+  if (VarIndices.size() != 2 || !MaybeV1Size.hasValue() ||
+      !MaybeV2Size.hasValue())
     return false;
 
   const uint64_t V1Size = MaybeV1Size.getValue();

diff  --git a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp
index 179f0633df06..2be23a56cc7b 100644
--- a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp
@@ -559,8 +559,7 @@ bool CFLAndersAAResult::FunctionInfo::mayAlias(
 
     if (RangePair.first != RangePair.second) {
       // Be conservative about unknown sizes
-      if (MaybeLHSSize == LocationSize::unknown() ||
-          MaybeRHSSize == LocationSize::unknown())
+      if (!MaybeLHSSize.hasValue() || !MaybeRHSSize.hasValue())
         return true;
 
       const uint64_t LHSSize = MaybeLHSSize.getValue();


        


More information about the llvm-commits mailing list