Skip to content

Commit b1f5508

Browse files
committed
[AA] Rename CaptureInfo -> CaptureAnalysis (NFC)
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.
1 parent abac5be commit b1f5508

File tree

7 files changed

+46
-43
lines changed

7 files changed

+46
-43
lines changed

llvm/include/llvm/Analysis/AliasAnalysis.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ static_assert(sizeof(AliasResult) == 4,
144144
/// << operator for AliasResult.
145145
raw_ostream &operator<<(raw_ostream &OS, AliasResult AR);
146146

147-
/// Virtual base class for providers of capture information.
148-
struct CaptureInfo {
149-
virtual ~CaptureInfo() = 0;
147+
/// Virtual base class for providers of capture analysis.
148+
struct CaptureAnalysis {
149+
virtual ~CaptureAnalysis() = 0;
150150

151151
/// Check whether Object is not captured before instruction I. If OrAt is
152152
/// true, captures by instruction I itself are also considered.
@@ -156,21 +156,21 @@ struct CaptureInfo {
156156
bool OrAt) = 0;
157157
};
158158

159-
/// Context-free CaptureInfo provider, which computes and caches whether an
159+
/// Context-free CaptureAnalysis provider, which computes and caches whether an
160160
/// object is captured in the function at all, but does not distinguish whether
161161
/// it was captured before or after the context instruction.
162-
class SimpleCaptureInfo final : public CaptureInfo {
162+
class SimpleCaptureAnalysis final : public CaptureAnalysis {
163163
SmallDenseMap<const Value *, bool, 8> IsCapturedCache;
164164

165165
public:
166166
bool isNotCapturedBefore(const Value *Object, const Instruction *I,
167167
bool OrAt) override;
168168
};
169169

170-
/// Context-sensitive CaptureInfo provider, which computes and caches the
170+
/// Context-sensitive CaptureAnalysis provider, which computes and caches the
171171
/// earliest common dominator closure of all captures. It provides a good
172172
/// approximation to a precise "captures before" analysis.
173-
class EarliestEscapeInfo final : public CaptureInfo {
173+
class EarliestEscapeAnalysis final : public CaptureAnalysis {
174174
DominatorTree &DT;
175175
const LoopInfo *LI;
176176

@@ -185,7 +185,7 @@ class EarliestEscapeInfo final : public CaptureInfo {
185185
DenseMap<Instruction *, TinyPtrVector<const Value *>> Inst2Obj;
186186

187187
public:
188-
EarliestEscapeInfo(DominatorTree &DT, const LoopInfo *LI = nullptr)
188+
EarliestEscapeAnalysis(DominatorTree &DT, const LoopInfo *LI = nullptr)
189189
: DT(DT), LI(LI) {}
190190

191191
bool isNotCapturedBefore(const Value *Object, const Instruction *I,
@@ -265,7 +265,7 @@ class AAQueryInfo {
265265
using AliasCacheT = SmallDenseMap<LocPair, CacheEntry, 8>;
266266
AliasCacheT AliasCache;
267267

268-
CaptureInfo *CI;
268+
CaptureAnalysis *CA;
269269

270270
/// Query depth used to distinguish recursive queries.
271271
unsigned Depth = 0;
@@ -298,15 +298,15 @@ class AAQueryInfo {
298298
/// passes that lazily update the DT while performing AA queries.
299299
bool UseDominatorTree = true;
300300

301-
AAQueryInfo(AAResults &AAR, CaptureInfo *CI) : AAR(AAR), CI(CI) {}
301+
AAQueryInfo(AAResults &AAR, CaptureAnalysis *CA) : AAR(AAR), CA(CA) {}
302302
};
303303

304-
/// AAQueryInfo that uses SimpleCaptureInfo.
304+
/// AAQueryInfo that uses SimpleCaptureAnalysis.
305305
class SimpleAAQueryInfo : public AAQueryInfo {
306-
SimpleCaptureInfo CI;
306+
SimpleCaptureAnalysis CA;
307307

308308
public:
309-
SimpleAAQueryInfo(AAResults &AAR) : AAQueryInfo(AAR, &CI) {}
309+
SimpleAAQueryInfo(AAResults &AAR) : AAQueryInfo(AAR, &CA) {}
310310
};
311311

312312
class BatchAAResults;
@@ -630,11 +630,12 @@ class AAResults {
630630
class BatchAAResults {
631631
AAResults &AA;
632632
AAQueryInfo AAQI;
633-
SimpleCaptureInfo SimpleCI;
633+
SimpleCaptureAnalysis SimpleCA;
634634

635635
public:
636-
BatchAAResults(AAResults &AAR) : AA(AAR), AAQI(AAR, &SimpleCI) {}
637-
BatchAAResults(AAResults &AAR, CaptureInfo *CI) : AA(AAR), AAQI(AAR, CI) {}
636+
BatchAAResults(AAResults &AAR) : AA(AAR), AAQI(AAR, &SimpleCA) {}
637+
BatchAAResults(AAResults &AAR, CaptureAnalysis *CA)
638+
: AA(AAR), AAQI(AAR, CA) {}
638639

639640
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
640641
return AA.alias(LocA, LocB, AAQI);

llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ class MemoryDependenceResults {
355355
const TargetLibraryInfo &TLI;
356356
DominatorTree &DT;
357357
PredIteratorCache PredCache;
358-
EarliestEscapeInfo EII;
358+
EarliestEscapeAnalysis EEA;
359359

360360
unsigned DefaultBlockScanLimit;
361361

@@ -367,7 +367,7 @@ class MemoryDependenceResults {
367367
MemoryDependenceResults(AAResults &AA, AssumptionCache &AC,
368368
const TargetLibraryInfo &TLI, DominatorTree &DT,
369369
unsigned DefaultBlockScanLimit)
370-
: AA(AA), AC(AC), TLI(TLI), DT(DT), EII(DT),
370+
: AA(AA), AC(AC), TLI(TLI), DT(DT), EEA(DT),
371371
DefaultBlockScanLimit(DefaultBlockScanLimit) {}
372372

373373
/// Handle invalidation in the new PM.

llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AssumptionCache;
2626
class CallBase;
2727
class CallInst;
2828
class DominatorTree;
29-
class EarliestEscapeInfo;
29+
class EarliestEscapeAnalysis;
3030
class Function;
3131
class Instruction;
3232
class LoadInst;
@@ -49,7 +49,7 @@ class MemCpyOptPass : public PassInfoMixin<MemCpyOptPass> {
4949
PostDominatorTree *PDT = nullptr;
5050
MemorySSA *MSSA = nullptr;
5151
MemorySSAUpdater *MSSAU = nullptr;
52-
EarliestEscapeInfo *EEI = nullptr;
52+
EarliestEscapeAnalysis *EEA = nullptr;
5353

5454
public:
5555
MemCpyOptPass() = default;

llvm/lib/Analysis/BasicAliasAnalysis.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,14 @@ static bool areBothVScale(const Value *V1, const Value *V2) {
191191
}
192192

193193
//===----------------------------------------------------------------------===//
194-
// CaptureInfo implementations
194+
// CaptureAnalysis implementations
195195
//===----------------------------------------------------------------------===//
196196

197-
CaptureInfo::~CaptureInfo() = default;
197+
CaptureAnalysis::~CaptureAnalysis() = default;
198198

199-
bool SimpleCaptureInfo::isNotCapturedBefore(const Value *Object,
200-
const Instruction *I, bool OrAt) {
199+
bool SimpleCaptureAnalysis::isNotCapturedBefore(const Value *Object,
200+
const Instruction *I,
201+
bool OrAt) {
201202
return isNonEscapingLocalObject(Object, &IsCapturedCache);
202203
}
203204

@@ -209,8 +210,9 @@ static bool isNotInCycle(const Instruction *I, const DominatorTree *DT,
209210
!isPotentiallyReachableFromMany(Succs, BB, nullptr, DT, LI);
210211
}
211212

212-
bool EarliestEscapeInfo::isNotCapturedBefore(const Value *Object,
213-
const Instruction *I, bool OrAt) {
213+
bool EarliestEscapeAnalysis::isNotCapturedBefore(const Value *Object,
214+
const Instruction *I,
215+
bool OrAt) {
214216
if (!isIdentifiedFunctionLocal(Object))
215217
return false;
216218

@@ -241,7 +243,7 @@ bool EarliestEscapeInfo::isNotCapturedBefore(const Value *Object,
241243
return !isPotentiallyReachable(Iter.first->second, I, nullptr, &DT, LI);
242244
}
243245

244-
void EarliestEscapeInfo::removeInstruction(Instruction *I) {
246+
void EarliestEscapeAnalysis::removeInstruction(Instruction *I) {
245247
auto Iter = Inst2Obj.find(I);
246248
if (Iter != Inst2Obj.end()) {
247249
for (const Value *Obj : Iter->second)
@@ -946,7 +948,7 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call,
946948
// Make sure the object has not escaped here, and then check that none of the
947949
// call arguments alias the object below.
948950
if (!isa<Constant>(Object) && Call != Object &&
949-
AAQI.CI->isNotCapturedBefore(Object, Call, /*OrAt*/ false)) {
951+
AAQI.CA->isNotCapturedBefore(Object, Call, /*OrAt*/ false)) {
950952

951953
// Optimistically assume that call doesn't touch Object and check this
952954
// assumption in the following loop.
@@ -1621,10 +1623,10 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
16211623
// temporary store the nocapture argument's value in a temporary memory
16221624
// location if that memory location doesn't escape. Or it may pass a
16231625
// nocapture value to other functions as long as they don't capture it.
1624-
if (isEscapeSource(O1) && AAQI.CI->isNotCapturedBefore(
1626+
if (isEscapeSource(O1) && AAQI.CA->isNotCapturedBefore(
16251627
O2, dyn_cast<Instruction>(O1), /*OrAt*/ true))
16261628
return AliasResult::NoAlias;
1627-
if (isEscapeSource(O2) && AAQI.CI->isNotCapturedBefore(
1629+
if (isEscapeSource(O2) && AAQI.CA->isNotCapturedBefore(
16281630
O1, dyn_cast<Instruction>(O2), /*OrAt*/ true))
16291631
return AliasResult::NoAlias;
16301632
}

llvm/lib/Analysis/MemoryDependenceAnalysis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ MemDepResult MemoryDependenceResults::getPointerDependencyFrom(
268268
MemDepResult MemoryDependenceResults::getPointerDependencyFrom(
269269
const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt,
270270
BasicBlock *BB, Instruction *QueryInst, unsigned *Limit) {
271-
BatchAAResults BatchAA(AA, &EII);
271+
BatchAAResults BatchAA(AA, &EEA);
272272
return getPointerDependencyFrom(MemLoc, isLoad, ScanIt, BB, QueryInst, Limit,
273273
BatchAA);
274274
}
@@ -1198,7 +1198,7 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB(
11981198
bool GotWorklistLimit = false;
11991199
LLVM_DEBUG(AssertSorted(*Cache));
12001200

1201-
BatchAAResults BatchAA(AA, &EII);
1201+
BatchAAResults BatchAA(AA, &EEA);
12021202
while (!Worklist.empty()) {
12031203
BasicBlock *BB = Worklist.pop_back_val();
12041204

@@ -1510,7 +1510,7 @@ void MemoryDependenceResults::invalidateCachedPredecessors() {
15101510
}
15111511

15121512
void MemoryDependenceResults::removeInstruction(Instruction *RemInst) {
1513-
EII.removeInstruction(RemInst);
1513+
EEA.removeInstruction(RemInst);
15141514

15151515
// Walk through the Non-local dependencies, removing this one as the value
15161516
// for any cached queries.

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ ConstantRangeList getIntersectedInitRangeList(ArrayRef<ArgumentInitInfo> Args,
883883
struct DSEState {
884884
Function &F;
885885
AliasAnalysis &AA;
886-
EarliestEscapeInfo EI;
886+
EarliestEscapeAnalysis EA;
887887

888888
/// The single BatchAA instance that is used to cache AA queries. It will
889889
/// not be invalidated over the whole run. This is safe, because:
@@ -943,7 +943,7 @@ struct DSEState {
943943
DSEState(Function &F, AliasAnalysis &AA, MemorySSA &MSSA, DominatorTree &DT,
944944
PostDominatorTree &PDT, const TargetLibraryInfo &TLI,
945945
const LoopInfo &LI)
946-
: F(F), AA(AA), EI(DT, &LI), BatchAA(AA, &EI), MSSA(MSSA), DT(DT),
946+
: F(F), AA(AA), EA(DT, &LI), BatchAA(AA, &EA), MSSA(MSSA), DT(DT),
947947
PDT(PDT), TLI(TLI), DL(F.getDataLayout()), LI(LI) {
948948
// Collect blocks with throwing instructions not modeled in MemorySSA and
949949
// alloc-like objects.
@@ -1850,7 +1850,7 @@ struct DSEState {
18501850
NowDeadInsts.push_back(OpI);
18511851
}
18521852

1853-
EI.removeInstruction(DeadInst);
1853+
EA.removeInstruction(DeadInst);
18541854
// Remove memory defs directly if they don't produce results, but only
18551855
// queue other dead instructions for later removal. They may have been
18561856
// used as memory locations that have been cached by BatchAA. Removing

llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static bool mayBeVisibleThroughUnwinding(Value *V, Instruction *Start,
283283

284284
void MemCpyOptPass::eraseInstruction(Instruction *I) {
285285
MSSAU->removeMemoryAccess(I);
286-
EEI->removeInstruction(I);
286+
EEA->removeInstruction(I);
287287
I->eraseFromParent();
288288
}
289289

@@ -638,7 +638,7 @@ bool MemCpyOptPass::processStoreOfLoad(StoreInst *SI, LoadInst *LI,
638638
if (!LI->isSimple() || !LI->hasOneUse() || LI->getParent() != SI->getParent())
639639
return false;
640640

641-
BatchAAResults BAA(*AA, EEI);
641+
BatchAAResults BAA(*AA, EEA);
642642
auto *T = LI->getType();
643643
// Don't introduce calls to memcpy/memmove intrinsics out of thin air if
644644
// the corresponding libcalls are not available.
@@ -1751,7 +1751,7 @@ bool MemCpyOptPass::processMemCpy(MemCpyInst *M, BasicBlock::iterator &BBI) {
17511751
return true;
17521752
}
17531753

1754-
BatchAAResults BAA(*AA, EEI);
1754+
BatchAAResults BAA(*AA, EEA);
17551755
// FIXME: Not using getClobberingMemoryAccess() here due to PR54682.
17561756
MemoryAccess *AnyClobber = MA->getDefiningAccess();
17571757
MemoryLocation DestLoc = MemoryLocation::getForDest(M);
@@ -1876,7 +1876,7 @@ bool MemCpyOptPass::processByValArgument(CallBase &CB, unsigned ArgNo) {
18761876
if (!CallAccess)
18771877
return false;
18781878
MemCpyInst *MDep = nullptr;
1879-
BatchAAResults BAA(*AA, EEI);
1879+
BatchAAResults BAA(*AA, EEA);
18801880
MemoryAccess *Clobber = MSSA->getWalker()->getClobberingMemoryAccess(
18811881
CallAccess->getDefiningAccess(), Loc, BAA);
18821882
if (auto *MD = dyn_cast<MemoryDef>(Clobber))
@@ -1949,7 +1949,7 @@ bool MemCpyOptPass::processByValArgument(CallBase &CB, unsigned ArgNo) {
19491949
/// 4. The memcpy src is not modified during the call. (ModRef check shows no
19501950
/// Mod.)
19511951
bool MemCpyOptPass::processImmutArgument(CallBase &CB, unsigned ArgNo) {
1952-
BatchAAResults BAA(*AA, EEI);
1952+
BatchAAResults BAA(*AA, EEA);
19531953
Value *ImmutArg = CB.getArgOperand(ArgNo);
19541954

19551955
// 1. Ensure passed argument is immutable during call.
@@ -2117,8 +2117,8 @@ bool MemCpyOptPass::runImpl(Function &F, TargetLibraryInfo *TLI_,
21172117
MSSA = MSSA_;
21182118
MemorySSAUpdater MSSAU_(MSSA_);
21192119
MSSAU = &MSSAU_;
2120-
EarliestEscapeInfo EEI_(*DT);
2121-
EEI = &EEI_;
2120+
EarliestEscapeAnalysis EEA_(*DT);
2121+
EEA = &EEA_;
21222122

21232123
while (true) {
21242124
if (!iterateOnFunction(F))

0 commit comments

Comments
 (0)