[llvm] [AA] Rename CaptureInfo -> CaptureAnalysis (NFC) (PR #116842)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 19 09:14:06 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
@llvm/pr-subscribers-llvm-transforms
Author: Nikita Popov (nikic)
<details>
<summary>Changes</summary>
I'd like to use the name CaptureInfo to represent the new attribute proposed at https://discourse.llvm.org/t/rfc-improvements-to-capture-tracking/81420, but it's already taken by AA, and I can't think of great alternatives (CaptureEffects would be something of a stretch).
As such, I'd like to rename CaptureInfo -> CaptureAnalysis in AA, which also seems like the more accurate terminology.
---
Full diff: https://github.com/llvm/llvm-project/pull/116842.diff
7 Files Affected:
- (modified) llvm/include/llvm/Analysis/AliasAnalysis.h (+17-16)
- (modified) llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h (+2-2)
- (modified) llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h (+2-2)
- (modified) llvm/lib/Analysis/BasicAliasAnalysis.cpp (+12-10)
- (modified) llvm/lib/Analysis/MemoryDependenceAnalysis.cpp (+3-3)
- (modified) llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp (+3-3)
- (modified) llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp (+7-7)
``````````diff
diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h b/llvm/include/llvm/Analysis/AliasAnalysis.h
index 9c6084d2d9deeb..60875577561dc4 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -144,9 +144,9 @@ static_assert(sizeof(AliasResult) == 4,
/// << operator for AliasResult.
raw_ostream &operator<<(raw_ostream &OS, AliasResult AR);
-/// Virtual base class for providers of capture information.
-struct CaptureInfo {
- virtual ~CaptureInfo() = 0;
+/// Virtual base class for providers of capture analysis.
+struct CaptureAnalysis {
+ virtual ~CaptureAnalysis() = 0;
/// Check whether Object is not captured before instruction I. If OrAt is
/// true, captures by instruction I itself are also considered.
@@ -156,10 +156,10 @@ struct CaptureInfo {
bool OrAt) = 0;
};
-/// Context-free CaptureInfo provider, which computes and caches whether an
+/// Context-free CaptureAnalysis provider, which computes and caches whether an
/// object is captured in the function at all, but does not distinguish whether
/// it was captured before or after the context instruction.
-class SimpleCaptureInfo final : public CaptureInfo {
+class SimpleCaptureAnalysis final : public CaptureAnalysis {
SmallDenseMap<const Value *, bool, 8> IsCapturedCache;
public:
@@ -167,10 +167,10 @@ class SimpleCaptureInfo final : public CaptureInfo {
bool OrAt) override;
};
-/// Context-sensitive CaptureInfo provider, which computes and caches the
+/// Context-sensitive CaptureAnalysis provider, which computes and caches the
/// earliest common dominator closure of all captures. It provides a good
/// approximation to a precise "captures before" analysis.
-class EarliestEscapeInfo final : public CaptureInfo {
+class EarliestEscapeAnalysis final : public CaptureAnalysis {
DominatorTree &DT;
const LoopInfo *LI;
@@ -185,7 +185,7 @@ class EarliestEscapeInfo final : public CaptureInfo {
DenseMap<Instruction *, TinyPtrVector<const Value *>> Inst2Obj;
public:
- EarliestEscapeInfo(DominatorTree &DT, const LoopInfo *LI = nullptr)
+ EarliestEscapeAnalysis(DominatorTree &DT, const LoopInfo *LI = nullptr)
: DT(DT), LI(LI) {}
bool isNotCapturedBefore(const Value *Object, const Instruction *I,
@@ -265,7 +265,7 @@ class AAQueryInfo {
using AliasCacheT = SmallDenseMap<LocPair, CacheEntry, 8>;
AliasCacheT AliasCache;
- CaptureInfo *CI;
+ CaptureAnalysis *CA;
/// Query depth used to distinguish recursive queries.
unsigned Depth = 0;
@@ -298,15 +298,15 @@ class AAQueryInfo {
/// passes that lazily update the DT while performing AA queries.
bool UseDominatorTree = true;
- AAQueryInfo(AAResults &AAR, CaptureInfo *CI) : AAR(AAR), CI(CI) {}
+ AAQueryInfo(AAResults &AAR, CaptureAnalysis *CA) : AAR(AAR), CA(CA) {}
};
-/// AAQueryInfo that uses SimpleCaptureInfo.
+/// AAQueryInfo that uses SimpleCaptureAnalysis.
class SimpleAAQueryInfo : public AAQueryInfo {
- SimpleCaptureInfo CI;
+ SimpleCaptureAnalysis CA;
public:
- SimpleAAQueryInfo(AAResults &AAR) : AAQueryInfo(AAR, &CI) {}
+ SimpleAAQueryInfo(AAResults &AAR) : AAQueryInfo(AAR, &CA) {}
};
class BatchAAResults;
@@ -630,11 +630,12 @@ class AAResults {
class BatchAAResults {
AAResults &AA;
AAQueryInfo AAQI;
- SimpleCaptureInfo SimpleCI;
+ SimpleCaptureAnalysis SimpleCA;
public:
- BatchAAResults(AAResults &AAR) : AA(AAR), AAQI(AAR, &SimpleCI) {}
- BatchAAResults(AAResults &AAR, CaptureInfo *CI) : AA(AAR), AAQI(AAR, CI) {}
+ BatchAAResults(AAResults &AAR) : AA(AAR), AAQI(AAR, &SimpleCA) {}
+ BatchAAResults(AAResults &AAR, CaptureAnalysis *CA)
+ : AA(AAR), AAQI(AAR, CA) {}
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
return AA.alias(LocA, LocB, AAQI);
diff --git a/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h b/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
index c31e663498d5f3..d6288f2aa061e4 100644
--- a/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
+++ b/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
@@ -355,7 +355,7 @@ class MemoryDependenceResults {
const TargetLibraryInfo &TLI;
DominatorTree &DT;
PredIteratorCache PredCache;
- EarliestEscapeInfo EII;
+ EarliestEscapeAnalysis EEA;
unsigned DefaultBlockScanLimit;
@@ -367,7 +367,7 @@ class MemoryDependenceResults {
MemoryDependenceResults(AAResults &AA, AssumptionCache &AC,
const TargetLibraryInfo &TLI, DominatorTree &DT,
unsigned DefaultBlockScanLimit)
- : AA(AA), AC(AC), TLI(TLI), DT(DT), EII(DT),
+ : AA(AA), AC(AC), TLI(TLI), DT(DT), EEA(DT),
DefaultBlockScanLimit(DefaultBlockScanLimit) {}
/// Handle invalidation in the new PM.
diff --git a/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h b/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
index e5f78ac2286833..023c9de28209c8 100644
--- a/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
+++ b/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h
@@ -26,7 +26,7 @@ class AssumptionCache;
class CallBase;
class CallInst;
class DominatorTree;
-class EarliestEscapeInfo;
+class EarliestEscapeAnalysis;
class Function;
class Instruction;
class LoadInst;
@@ -49,7 +49,7 @@ class MemCpyOptPass : public PassInfoMixin<MemCpyOptPass> {
PostDominatorTree *PDT = nullptr;
MemorySSA *MSSA = nullptr;
MemorySSAUpdater *MSSAU = nullptr;
- EarliestEscapeInfo *EEI = nullptr;
+ EarliestEscapeAnalysis *EEA = nullptr;
public:
MemCpyOptPass() = default;
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 1dcdad01f4c809..178ad863eb06a6 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -191,13 +191,14 @@ static bool areBothVScale(const Value *V1, const Value *V2) {
}
//===----------------------------------------------------------------------===//
-// CaptureInfo implementations
+// CaptureAnalysis implementations
//===----------------------------------------------------------------------===//
-CaptureInfo::~CaptureInfo() = default;
+CaptureAnalysis::~CaptureAnalysis() = default;
-bool SimpleCaptureInfo::isNotCapturedBefore(const Value *Object,
- const Instruction *I, bool OrAt) {
+bool SimpleCaptureAnalysis::isNotCapturedBefore(const Value *Object,
+ const Instruction *I,
+ bool OrAt) {
return isNonEscapingLocalObject(Object, &IsCapturedCache);
}
@@ -209,8 +210,9 @@ static bool isNotInCycle(const Instruction *I, const DominatorTree *DT,
!isPotentiallyReachableFromMany(Succs, BB, nullptr, DT, LI);
}
-bool EarliestEscapeInfo::isNotCapturedBefore(const Value *Object,
- const Instruction *I, bool OrAt) {
+bool EarliestEscapeAnalysis::isNotCapturedBefore(const Value *Object,
+ const Instruction *I,
+ bool OrAt) {
if (!isIdentifiedFunctionLocal(Object))
return false;
@@ -241,7 +243,7 @@ bool EarliestEscapeInfo::isNotCapturedBefore(const Value *Object,
return !isPotentiallyReachable(Iter.first->second, I, nullptr, &DT, LI);
}
-void EarliestEscapeInfo::removeInstruction(Instruction *I) {
+void EarliestEscapeAnalysis::removeInstruction(Instruction *I) {
auto Iter = Inst2Obj.find(I);
if (Iter != Inst2Obj.end()) {
for (const Value *Obj : Iter->second)
@@ -946,7 +948,7 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call,
// Make sure the object has not escaped here, and then check that none of the
// call arguments alias the object below.
if (!isa<Constant>(Object) && Call != Object &&
- AAQI.CI->isNotCapturedBefore(Object, Call, /*OrAt*/ false)) {
+ AAQI.CA->isNotCapturedBefore(Object, Call, /*OrAt*/ false)) {
// Optimistically assume that call doesn't touch Object and check this
// assumption in the following loop.
@@ -1621,10 +1623,10 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
// temporary store the nocapture argument's value in a temporary memory
// location if that memory location doesn't escape. Or it may pass a
// nocapture value to other functions as long as they don't capture it.
- if (isEscapeSource(O1) && AAQI.CI->isNotCapturedBefore(
+ if (isEscapeSource(O1) && AAQI.CA->isNotCapturedBefore(
O2, dyn_cast<Instruction>(O1), /*OrAt*/ true))
return AliasResult::NoAlias;
- if (isEscapeSource(O2) && AAQI.CI->isNotCapturedBefore(
+ if (isEscapeSource(O2) && AAQI.CA->isNotCapturedBefore(
O1, dyn_cast<Instruction>(O2), /*OrAt*/ true))
return AliasResult::NoAlias;
}
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index c5fba184cd0850..c40bbd9e18e792 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -268,7 +268,7 @@ MemDepResult MemoryDependenceResults::getPointerDependencyFrom(
MemDepResult MemoryDependenceResults::getPointerDependencyFrom(
const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt,
BasicBlock *BB, Instruction *QueryInst, unsigned *Limit) {
- BatchAAResults BatchAA(AA, &EII);
+ BatchAAResults BatchAA(AA, &EEA);
return getPointerDependencyFrom(MemLoc, isLoad, ScanIt, BB, QueryInst, Limit,
BatchAA);
}
@@ -1198,7 +1198,7 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB(
bool GotWorklistLimit = false;
LLVM_DEBUG(AssertSorted(*Cache));
- BatchAAResults BatchAA(AA, &EII);
+ BatchAAResults BatchAA(AA, &EEA);
while (!Worklist.empty()) {
BasicBlock *BB = Worklist.pop_back_val();
@@ -1510,7 +1510,7 @@ void MemoryDependenceResults::invalidateCachedPredecessors() {
}
void MemoryDependenceResults::removeInstruction(Instruction *RemInst) {
- EII.removeInstruction(RemInst);
+ EEA.removeInstruction(RemInst);
// Walk through the Non-local dependencies, removing this one as the value
// for any cached queries.
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index b619248c59de0b..5555b5e29cc74f 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -883,7 +883,7 @@ ConstantRangeList getIntersectedInitRangeList(ArrayRef<ArgumentInitInfo> Args,
struct DSEState {
Function &F;
AliasAnalysis &AA;
- EarliestEscapeInfo EI;
+ EarliestEscapeAnalysis EA;
/// The single BatchAA instance that is used to cache AA queries. It will
/// not be invalidated over the whole run. This is safe, because:
@@ -943,7 +943,7 @@ struct DSEState {
DSEState(Function &F, AliasAnalysis &AA, MemorySSA &MSSA, DominatorTree &DT,
PostDominatorTree &PDT, const TargetLibraryInfo &TLI,
const LoopInfo &LI)
- : F(F), AA(AA), EI(DT, &LI), BatchAA(AA, &EI), MSSA(MSSA), DT(DT),
+ : F(F), AA(AA), EA(DT, &LI), BatchAA(AA, &EA), MSSA(MSSA), DT(DT),
PDT(PDT), TLI(TLI), DL(F.getDataLayout()), LI(LI) {
// Collect blocks with throwing instructions not modeled in MemorySSA and
// alloc-like objects.
@@ -1850,7 +1850,7 @@ struct DSEState {
NowDeadInsts.push_back(OpI);
}
- EI.removeInstruction(DeadInst);
+ EA.removeInstruction(DeadInst);
// Remove memory defs directly if they don't produce results, but only
// queue other dead instructions for later removal. They may have been
// used as memory locations that have been cached by BatchAA. Removing
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index fb662daf03cbe7..e9e1071ea210c4 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -283,7 +283,7 @@ static bool mayBeVisibleThroughUnwinding(Value *V, Instruction *Start,
void MemCpyOptPass::eraseInstruction(Instruction *I) {
MSSAU->removeMemoryAccess(I);
- EEI->removeInstruction(I);
+ EEA->removeInstruction(I);
I->eraseFromParent();
}
@@ -638,7 +638,7 @@ bool MemCpyOptPass::processStoreOfLoad(StoreInst *SI, LoadInst *LI,
if (!LI->isSimple() || !LI->hasOneUse() || LI->getParent() != SI->getParent())
return false;
- BatchAAResults BAA(*AA, EEI);
+ BatchAAResults BAA(*AA, EEA);
auto *T = LI->getType();
// Don't introduce calls to memcpy/memmove intrinsics out of thin air if
// the corresponding libcalls are not available.
@@ -1751,7 +1751,7 @@ bool MemCpyOptPass::processMemCpy(MemCpyInst *M, BasicBlock::iterator &BBI) {
return true;
}
- BatchAAResults BAA(*AA, EEI);
+ BatchAAResults BAA(*AA, EEA);
// FIXME: Not using getClobberingMemoryAccess() here due to PR54682.
MemoryAccess *AnyClobber = MA->getDefiningAccess();
MemoryLocation DestLoc = MemoryLocation::getForDest(M);
@@ -1876,7 +1876,7 @@ bool MemCpyOptPass::processByValArgument(CallBase &CB, unsigned ArgNo) {
if (!CallAccess)
return false;
MemCpyInst *MDep = nullptr;
- BatchAAResults BAA(*AA, EEI);
+ BatchAAResults BAA(*AA, EEA);
MemoryAccess *Clobber = MSSA->getWalker()->getClobberingMemoryAccess(
CallAccess->getDefiningAccess(), Loc, BAA);
if (auto *MD = dyn_cast<MemoryDef>(Clobber))
@@ -1949,7 +1949,7 @@ bool MemCpyOptPass::processByValArgument(CallBase &CB, unsigned ArgNo) {
/// 4. The memcpy src is not modified during the call. (ModRef check shows no
/// Mod.)
bool MemCpyOptPass::processImmutArgument(CallBase &CB, unsigned ArgNo) {
- BatchAAResults BAA(*AA, EEI);
+ BatchAAResults BAA(*AA, EEA);
Value *ImmutArg = CB.getArgOperand(ArgNo);
// 1. Ensure passed argument is immutable during call.
@@ -2117,8 +2117,8 @@ bool MemCpyOptPass::runImpl(Function &F, TargetLibraryInfo *TLI_,
MSSA = MSSA_;
MemorySSAUpdater MSSAU_(MSSA_);
MSSAU = &MSSAU_;
- EarliestEscapeInfo EEI_(*DT);
- EEI = &EEI_;
+ EarliestEscapeAnalysis EEA_(*DT);
+ EEA = &EEA_;
while (true) {
if (!iterateOnFunction(F))
``````````
</details>
https://github.com/llvm/llvm-project/pull/116842
More information about the llvm-commits
mailing list