summaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-07-29 20:15:26 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-07-29 20:15:26 +0000
commit344a3780b2e33f6ca763666c380202b18aab72a3 (patch)
treef0b203ee6eb71d7fdd792373e3c81eb18d6934dd /llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
parentb60736ec1405bb0a8dd40989f67ef4c93da068ab (diff)
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp b/llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
index 8f289feb3dcf..2262fc9d7913 100644
--- a/llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
@@ -19,6 +19,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
+#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/InitializePasses.h"
using namespace llvm;
@@ -28,7 +29,7 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
// pointer values are. This allows the code below to ignore this special
// case.
if (LocA.Size.isZero() || LocB.Size.isZero())
- return NoAlias;
+ return AliasResult::NoAlias;
// This is SCEVAAResult. Get the SCEVs!
const SCEV *AS = SE.getSCEV(const_cast<Value *>(LocA.Ptr));
@@ -36,7 +37,7 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
// If they evaluate to the same expression, it's a MustAlias.
if (AS == BS)
- return MustAlias;
+ return AliasResult::MustAlias;
// If something is known about the difference between the two addresses,
// see if it's enough to prove a NoAlias.
@@ -56,9 +57,10 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
// Test whether the difference is known to be great enough that memory of
// the given sizes don't overlap. This assumes that ASizeInt and BSizeInt
// are non-zero, which is special-cased above.
- if (ASizeInt.ule(SE.getUnsignedRange(BA).getUnsignedMin()) &&
+ if (!isa<SCEVCouldNotCompute>(BA) &&
+ ASizeInt.ule(SE.getUnsignedRange(BA).getUnsignedMin()) &&
(-BSizeInt).uge(SE.getUnsignedRange(BA).getUnsignedMax()))
- return NoAlias;
+ return AliasResult::NoAlias;
// Folding the subtraction while preserving range information can be tricky
// (because of INT_MIN, etc.); if the prior test failed, swap AS and BS
@@ -70,9 +72,10 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
// Test whether the difference is known to be great enough that memory of
// the given sizes don't overlap. This assumes that ASizeInt and BSizeInt
// are non-zero, which is special-cased above.
- if (BSizeInt.ule(SE.getUnsignedRange(AB).getUnsignedMin()) &&
+ if (!isa<SCEVCouldNotCompute>(AB) &&
+ BSizeInt.ule(SE.getUnsignedRange(AB).getUnsignedMin()) &&
(-ASizeInt).uge(SE.getUnsignedRange(AB).getUnsignedMax()))
- return NoAlias;
+ return AliasResult::NoAlias;
}
// If ScalarEvolution can find an underlying object, form a new query.
@@ -89,8 +92,8 @@ AliasResult SCEVAAResult::alias(const MemoryLocation &LocA,
BO ? LocationSize::beforeOrAfterPointer()
: LocB.Size,
BO ? AAMDNodes() : LocB.AATags),
- AAQI) == NoAlias)
- return NoAlias;
+ AAQI) == AliasResult::NoAlias)
+ return AliasResult::NoAlias;
// Forward the query to the next analysis.
return AAResultBase::alias(LocA, LocB, AAQI);
@@ -117,6 +120,13 @@ Value *SCEVAAResult::GetBaseValue(const SCEV *S) {
return nullptr;
}
+bool SCEVAAResult::invalidate(Function &Fn, const PreservedAnalyses &PA,
+ FunctionAnalysisManager::Invalidator &Inv) {
+ // We don't care if this analysis itself is preserved, it has no state. But
+ // we need to check that the analyses it depends on have been.
+ return Inv.invalidate<ScalarEvolutionAnalysis>(Fn, PA);
+}
+
AnalysisKey SCEVAA::Key;
SCEVAAResult SCEVAA::run(Function &F, FunctionAnalysisManager &AM) {