aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Analysis/AliasSetTracker.h9
-rw-r--r--llvm/include/llvm/LinkAllPasses.h3
-rw-r--r--llvm/lib/Analysis/AliasSetTracker.cpp20
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp5
-rw-r--r--llvm/lib/Transforms/Scalar/LICM.cpp4
-rw-r--r--llvm/lib/Transforms/Scalar/LoopRerollPass.cpp4
-rw-r--r--llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp3
-rw-r--r--llvm/unittests/Analysis/AliasSetTrackerTest.cpp3
-rw-r--r--polly/include/polly/ScopDetection.h9
-rw-r--r--polly/lib/Analysis/ScopBuilder.cpp3
10 files changed, 33 insertions, 30 deletions
diff --git a/llvm/include/llvm/Analysis/AliasSetTracker.h b/llvm/include/llvm/Analysis/AliasSetTracker.h
index 25733fd..23eaa3c 100644
--- a/llvm/include/llvm/Analysis/AliasSetTracker.h
+++ b/llvm/include/llvm/Analysis/AliasSetTracker.h
@@ -33,7 +33,6 @@
namespace llvm {
-class AAResults;
class AliasResult;
class AliasSetTracker;
class AnyMemSetInst;
@@ -287,7 +286,7 @@ private:
void addPointer(AliasSetTracker &AST, PointerRec &Entry, LocationSize Size,
const AAMDNodes &AAInfo, bool KnownMustAlias = false,
bool SkipSizeUpdate = false);
- void addUnknownInst(Instruction *I, AAResults &AA);
+ void addUnknownInst(Instruction *I, BatchAAResults &AA);
public:
/// If the specified pointer "may" (or must) alias one of the members in the
@@ -303,7 +302,7 @@ inline raw_ostream& operator<<(raw_ostream &OS, const AliasSet &AS) {
}
class AliasSetTracker {
- AAResults &AA;
+ BatchAAResults &AA;
ilist<AliasSet> AliasSets;
using PointerMapType = DenseMap<AssertingVH<Value>, AliasSet::PointerRec *>;
@@ -314,7 +313,7 @@ class AliasSetTracker {
public:
/// Create an empty collection of AliasSets, and use the specified alias
/// analysis object to disambiguate load and store addresses.
- explicit AliasSetTracker(AAResults &AA) : AA(AA) {}
+ explicit AliasSetTracker(BatchAAResults &AA) : AA(AA) {}
~AliasSetTracker() { clear(); }
/// These methods are used to add different types of instructions to the alias
@@ -352,7 +351,7 @@ public:
AliasSet &getAliasSetFor(const MemoryLocation &MemLoc);
/// Return the underlying alias analysis object used by this tracker.
- AAResults &getAliasAnalysis() const { return AA; }
+ BatchAAResults &getAliasAnalysis() const { return AA; }
using iterator = ilist<AliasSet>::iterator;
using const_iterator = ilist<AliasSet>::const_iterator;
diff --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h
index 56cea7d..d5c3fb9 100644
--- a/llvm/include/llvm/LinkAllPasses.h
+++ b/llvm/include/llvm/LinkAllPasses.h
@@ -227,7 +227,8 @@ namespace {
llvm::TargetLibraryInfoImpl TLII;
llvm::TargetLibraryInfo TLI(TLII);
llvm::AliasAnalysis AA(TLI);
- llvm::AliasSetTracker X(AA);
+ llvm::BatchAAResults BAA(AA);
+ llvm::AliasSetTracker X(BAA);
X.add(nullptr, llvm::LocationSize::beforeOrAfterPointer(),
llvm::AAMDNodes()); // for -print-alias-sets
(void) llvm::AreStatisticsEnabled();
diff --git a/llvm/lib/Analysis/AliasSetTracker.cpp b/llvm/lib/Analysis/AliasSetTracker.cpp
index dcc45ef..526642d 100644
--- a/llvm/lib/Analysis/AliasSetTracker.cpp
+++ b/llvm/lib/Analysis/AliasSetTracker.cpp
@@ -132,7 +132,7 @@ void AliasSet::addPointer(AliasSetTracker &AST, PointerRec &Entry,
if (isMustAlias())
if (PointerRec *P = getSomePointer()) {
if (!KnownMustAlias) {
- AliasAnalysis &AA = AST.getAliasAnalysis();
+ BatchAAResults &AA = AST.getAliasAnalysis();
AliasResult Result = AA.alias(
MemoryLocation(P->getValue(), P->getSize(), P->getAAInfo()),
MemoryLocation(Entry.getValue(), Size, AAInfo));
@@ -161,7 +161,7 @@ void AliasSet::addPointer(AliasSetTracker &AST, PointerRec &Entry,
AST.TotalMayAliasSetSize++;
}
-void AliasSet::addUnknownInst(Instruction *I, AliasAnalysis &AA) {
+void AliasSet::addUnknownInst(Instruction *I, BatchAAResults &AA) {
if (UnknownInsts.empty())
addRef();
UnknownInsts.emplace_back(I);
@@ -271,12 +271,11 @@ AliasSet *AliasSetTracker::mergeAliasSetsForPointer(const Value *Ptr,
bool &MustAliasAll) {
AliasSet *FoundSet = nullptr;
MustAliasAll = true;
- BatchAAResults BatchAA(AA);
for (AliasSet &AS : llvm::make_early_inc_range(*this)) {
if (AS.Forward)
continue;
- AliasResult AR = AS.aliasesPointer(Ptr, Size, AAInfo, BatchAA);
+ AliasResult AR = AS.aliasesPointer(Ptr, Size, AAInfo, AA);
if (AR == AliasResult::NoAlias)
continue;
@@ -288,7 +287,7 @@ AliasSet *AliasSetTracker::mergeAliasSetsForPointer(const Value *Ptr,
FoundSet = &AS;
} else {
// Otherwise, we must merge the sets.
- FoundSet->mergeSetIn(AS, *this, BatchAA);
+ FoundSet->mergeSetIn(AS, *this, AA);
}
}
@@ -296,17 +295,16 @@ AliasSet *AliasSetTracker::mergeAliasSetsForPointer(const Value *Ptr,
}
AliasSet *AliasSetTracker::findAliasSetForUnknownInst(Instruction *Inst) {
- BatchAAResults BatchAA(AA);
AliasSet *FoundSet = nullptr;
for (AliasSet &AS : llvm::make_early_inc_range(*this)) {
- if (AS.Forward || !AS.aliasesUnknownInst(Inst, BatchAA))
+ if (AS.Forward || !AS.aliasesUnknownInst(Inst, AA))
continue;
if (!FoundSet) {
// If this is the first alias set ptr can go into, remember it.
FoundSet = &AS;
} else {
// Otherwise, we must merge the sets.
- FoundSet->mergeSetIn(AS, *this, BatchAA);
+ FoundSet->mergeSetIn(AS, *this, AA);
}
}
return FoundSet;
@@ -525,7 +523,6 @@ AliasSet &AliasSetTracker::mergeAllAliasSets() {
AliasAnyAS->Access = AliasSet::ModRefAccess;
AliasAnyAS->AliasAny = true;
- BatchAAResults BatchAA(AA);
for (auto *Cur : ASVector) {
// If Cur was already forwarding, just forward to the new AS instead.
AliasSet *FwdTo = Cur->Forward;
@@ -537,7 +534,7 @@ AliasSet &AliasSetTracker::mergeAllAliasSets() {
}
// Otherwise, perform the actual merge.
- AliasAnyAS->mergeSetIn(*Cur, *this, BatchAA);
+ AliasAnyAS->mergeSetIn(*Cur, *this, AA);
}
return *AliasAnyAS;
@@ -625,7 +622,8 @@ AliasSetsPrinterPass::AliasSetsPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses AliasSetsPrinterPass::run(Function &F,
FunctionAnalysisManager &AM) {
auto &AA = AM.getResult<AAManager>(F);
- AliasSetTracker Tracker(AA);
+ BatchAAResults BatchAA(AA);
+ AliasSetTracker Tracker(BatchAA);
OS << "Alias sets for function '" << F.getName() << "':\n";
for (Instruction &I : instructions(F))
Tracker.add(&I);
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 56175ea..1bc2f6b 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -622,7 +622,7 @@ public:
AccessAnalysis(Loop *TheLoop, AAResults *AA, LoopInfo *LI,
MemoryDepChecker::DepCandidates &DA,
PredicatedScalarEvolution &PSE)
- : TheLoop(TheLoop), AST(*AA), LI(LI), DepCands(DA), PSE(PSE) {}
+ : TheLoop(TheLoop), BAA(*AA), AST(BAA), LI(LI), DepCands(DA), PSE(PSE) {}
/// Register a load and whether it is only read from.
void addLoad(MemoryLocation &Loc, Type *AccessTy, bool IsReadOnly) {
@@ -704,6 +704,9 @@ private:
/// Set of pointers that are read only.
SmallPtrSet<Value*, 16> ReadOnlyPtr;
+ /// Batched alias analysis results.
+ BatchAAResults BAA;
+
/// An alias set tracker to partition the access set by underlying object and
//intrinsic property (such as TBAA metadata).
AliasSetTracker AST;
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index cf52283..4f8bdda 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -2267,7 +2267,8 @@ static void foreachMemoryAccess(MemorySSA *MSSA, Loop *L,
static SmallVector<SmallSetVector<Value *, 8>, 0>
collectPromotionCandidates(MemorySSA *MSSA, AliasAnalysis *AA, Loop *L) {
- AliasSetTracker AST(*AA);
+ BatchAAResults BatchAA(*AA);
+ AliasSetTracker AST(BatchAA);
auto IsPotentiallyPromotable = [L](const Instruction *I) {
if (const auto *SI = dyn_cast<StoreInst>(I))
@@ -2296,7 +2297,6 @@ collectPromotionCandidates(MemorySSA *MSSA, AliasAnalysis *AA, Loop *L) {
return {}; // Nothing to promote...
// Discard any sets for which there is an aliasing non-promotable access.
- BatchAAResults BatchAA(*AA);
foreachMemoryAccess(MSSA, L, [&](Instruction *I) {
if (AttemptingPromotion.contains(I))
return;
diff --git a/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp b/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp
index 8ea1a56..08fb010 100644
--- a/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp
@@ -1224,13 +1224,14 @@ bool LoopReroll::DAGRootTracker::validate(ReductionTracker &Reductions) {
dbgs() << "LRR: " << KV.second.find_first() << "\t" << *KV.first << "\n";
});
+ BatchAAResults BatchAA(*AA);
for (unsigned Iter = 1; Iter < Scale; ++Iter) {
// In addition to regular aliasing information, we need to look for
// instructions from later (future) iterations that have side effects
// preventing us from reordering them past other instructions with side
// effects.
bool FutureSideEffects = false;
- AliasSetTracker AST(*AA);
+ AliasSetTracker AST(BatchAA);
// The map between instructions in f(%iv.(i+1)) and f(%iv).
DenseMap<Value *, Value *> BaseMap;
@@ -1327,7 +1328,6 @@ bool LoopReroll::DAGRootTracker::validate(ReductionTracker &Reductions) {
// tracker. If we do, then we depend on a future iteration, and we
// can't reroll.
if (RootInst->mayReadFromMemory()) {
- BatchAAResults BatchAA(*AA);
for (auto &K : AST) {
if (K.aliasesUnknownInst(RootInst, BatchAA)) {
LLVM_DEBUG(dbgs() << "LRR: iteration root match failed at "
diff --git a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
index 38ebfe5..848be25 100644
--- a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
@@ -256,7 +256,8 @@ bool LoopVersioningLICM::legalLoopStructure() {
/// LoopVersioningLICM.
bool LoopVersioningLICM::legalLoopMemoryAccesses() {
// Loop over the body of this loop, construct AST.
- AliasSetTracker AST(*AA);
+ BatchAAResults BAA(*AA);
+ AliasSetTracker AST(BAA);
for (auto *Block : CurLoop->getBlocks()) {
// Ignore blocks in subloops.
if (LI.getLoopFor(Block) == CurLoop)
diff --git a/llvm/unittests/Analysis/AliasSetTrackerTest.cpp b/llvm/unittests/Analysis/AliasSetTrackerTest.cpp
index b8d295c..d2ee4db 100644
--- a/llvm/unittests/Analysis/AliasSetTrackerTest.cpp
+++ b/llvm/unittests/Analysis/AliasSetTrackerTest.cpp
@@ -68,7 +68,8 @@ TEST(AliasSetTracker, AliasUnknownInst) {
// Initialize the alias set tracker for the @test function.
Function *Test = M->getFunction("test");
ASSERT_NE(Test, nullptr);
- AliasSetTracker AST(AA);
+ BatchAAResults BAA(AA);
+ AliasSetTracker AST(BAA);
for (auto &BB : *Test)
AST.add(BB);
// There should be 2 disjoint alias sets. 1 from each call.
diff --git a/polly/include/polly/ScopDetection.h b/polly/include/polly/ScopDetection.h
index 8fe60d6..5759f75 100644
--- a/polly/include/polly/ScopDetection.h
+++ b/polly/include/polly/ScopDetection.h
@@ -48,22 +48,20 @@
#include "polly/ScopDetectionDiagnostic.h"
#include "polly/Support/ScopHelper.h"
+#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AliasSetTracker.h"
#include "llvm/Analysis/RegionInfo.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/Pass.h"
#include <set>
-namespace llvm {
-class AAResults;
-} // namespace llvm
-
namespace polly {
using llvm::AAResults;
using llvm::AliasSetTracker;
using llvm::AnalysisInfoMixin;
using llvm::AnalysisKey;
using llvm::AnalysisUsage;
+using llvm::BatchAAResults;
using llvm::BranchInst;
using llvm::CallInst;
using llvm::DenseMap;
@@ -142,6 +140,7 @@ public:
/// Context variables for SCoP detection.
struct DetectionContext {
Region &CurRegion; // The region to check.
+ BatchAAResults BAA; // The batched alias analysis results.
AliasSetTracker AST; // The AliasSetTracker to hold the alias information.
bool Verifying; // If we are in the verification phase?
@@ -189,7 +188,7 @@ public:
/// Initialize a DetectionContext from scratch.
DetectionContext(Region &R, AAResults &AA, bool Verify)
- : CurRegion(R), AST(AA), Verifying(Verify), Log(&R) {}
+ : CurRegion(R), BAA(AA), AST(BAA), Verifying(Verify), Log(&R) {}
};
/// Helper data structure to collect statistics about loop counts.
diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp
index 986e06b..ad77c4a 100644
--- a/polly/lib/Analysis/ScopBuilder.cpp
+++ b/polly/lib/Analysis/ScopBuilder.cpp
@@ -3205,7 +3205,8 @@ bool ScopBuilder::buildAliasChecks() {
std::tuple<ScopBuilder::AliasGroupVectorTy, DenseSet<const ScopArrayInfo *>>
ScopBuilder::buildAliasGroupsForAccesses() {
- AliasSetTracker AST(AA);
+ BatchAAResults BAA(AA);
+ AliasSetTracker AST(BAA);
DenseMap<Value *, MemoryAccess *> PtrToAcc;
DenseSet<const ScopArrayInfo *> HasWriteAccess;