Skip to content

Commit

Permalink
[AST] Use BatchAA in aliasesUnknownInst() (NFCI)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Sep 9, 2022
1 parent 20df17f commit a9f312c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion llvm/include/llvm/Analysis/AliasSetTracker.h
Expand Up @@ -37,6 +37,7 @@ class AliasSetTracker;
class AnyMemSetInst;
class AnyMemTransferInst;
class BasicBlock;
class BatchAAResults;
class LoadInst;
class raw_ostream;
class StoreInst;
Expand Down Expand Up @@ -311,7 +312,7 @@ class AliasSet : public ilist_node<AliasSet> {
/// set return the appropriate AliasResult. Otherwise return NoAlias.
AliasResult aliasesPointer(const Value *Ptr, LocationSize Size,
const AAMDNodes &AAInfo, AAResults &AA) const;
bool aliasesUnknownInst(const Instruction *Inst, AAResults &AA) const;
bool aliasesUnknownInst(const Instruction *Inst, BatchAAResults &AA) const;
};

inline raw_ostream& operator<<(raw_ostream &OS, const AliasSet &AS) {
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Analysis/AliasSetTracker.cpp
Expand Up @@ -228,7 +228,7 @@ AliasResult AliasSet::aliasesPointer(const Value *Ptr, LocationSize Size,
}

bool AliasSet::aliasesUnknownInst(const Instruction *Inst,
AliasAnalysis &AA) const {
BatchAAResults &AA) const {

if (AliasAny)
return true;
Expand Down Expand Up @@ -299,9 +299,10 @@ 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, AA))
if (AS.Forward || !AS.aliasesUnknownInst(Inst, BatchAA))
continue;
if (!FoundSet) {
// If this is the first alias set ptr can go into, remember it.
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Transforms/Scalar/LICM.cpp
Expand Up @@ -2254,12 +2254,13 @@ 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;

llvm::erase_if(Sets, [&](const AliasSet *AS) {
return AS->aliasesUnknownInst(I, *AA);
return AS->aliasesUnknownInst(I, BatchAA);
});
});

Expand Down
6 changes: 4 additions & 2 deletions llvm/lib/Transforms/Scalar/LoopRerollPass.cpp
Expand Up @@ -1326,15 +1326,17 @@ bool LoopReroll::DAGRootTracker::validate(ReductionTracker &Reductions) {
// Make sure that we don't alias with any instruction in the alias set
// tracker. If we do, then we depend on a future iteration, and we
// can't reroll.
if (RootInst->mayReadFromMemory())
if (RootInst->mayReadFromMemory()) {
BatchAAResults BatchAA(*AA);
for (auto &K : AST) {
if (K.aliasesUnknownInst(RootInst, *AA)) {
if (K.aliasesUnknownInst(RootInst, BatchAA)) {
LLVM_DEBUG(dbgs() << "LRR: iteration root match failed at "
<< *BaseInst << " vs. " << *RootInst
<< " (depends on future store)\n");
return false;
}
}
}

// If we've past an instruction from a future iteration that may have
// side effects, and this instruction might also, then we can't reorder
Expand Down

0 comments on commit a9f312c

Please sign in to comment.