Skip to content

Commit e6bca0e

Browse files
committed
Rename WeakVH to WeakTrackingVH; NFC
This relands r301424. llvm-svn: 301812
1 parent 2fa3604 commit e6bca0e

40 files changed

+201
-207
lines changed

llvm/include/llvm/Analysis/AliasSetTracker.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ class AliasSet : public ilist_node<AliasSet> {
121121
AliasSet *Forward;
122122

123123
/// All instructions without a specific address in this alias set.
124-
/// In rare cases this vector can have a null'ed out WeakVH
124+
/// In rare cases this vector can have a null'ed out WeakTrackingVH
125125
/// instances (can happen if some other loop pass deletes an
126126
/// instruction in this list).
127-
std::vector<WeakVH> UnknownInsts;
127+
std::vector<WeakTrackingVH> UnknownInsts;
128128

129129
/// Number of nodes pointing to this AliasSet plus the number of AliasSets
130130
/// forwarding to it.

llvm/include/llvm/Analysis/AssumptionCache.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class AssumptionCache {
4343

4444
/// \brief Vector of weak value handles to calls of the @llvm.assume
4545
/// intrinsic.
46-
SmallVector<WeakVH, 4> AssumeHandles;
46+
SmallVector<WeakTrackingVH, 4> AssumeHandles;
4747

4848
class AffectedValueCallbackVH final : public CallbackVH {
4949
AssumptionCache *AC;
@@ -62,12 +62,12 @@ class AssumptionCache {
6262
/// \brief A map of values about which an assumption might be providing
6363
/// information to the relevant set of assumptions.
6464
using AffectedValuesMap =
65-
DenseMap<AffectedValueCallbackVH, SmallVector<WeakVH, 1>,
66-
AffectedValueCallbackVH::DMI>;
65+
DenseMap<AffectedValueCallbackVH, SmallVector<WeakTrackingVH, 1>,
66+
AffectedValueCallbackVH::DMI>;
6767
AffectedValuesMap AffectedValues;
6868

6969
/// Get the vector of assumptions which affect a value from the cache.
70-
SmallVector<WeakVH, 1> &getOrInsertAffectedValues(Value *V);
70+
SmallVector<WeakTrackingVH, 1> &getOrInsertAffectedValues(Value *V);
7171

7272
/// Copy affected values in the cache for OV to be affected values for NV.
7373
void copyAffectedValuesInCache(Value *OV, Value *NV);
@@ -120,20 +120,20 @@ class AssumptionCache {
120120
/// FIXME: We should replace this with pointee_iterator<filter_iterator<...>>
121121
/// when we can write that to filter out the null values. Then caller code
122122
/// will become simpler.
123-
MutableArrayRef<WeakVH> assumptions() {
123+
MutableArrayRef<WeakTrackingVH> assumptions() {
124124
if (!Scanned)
125125
scanFunction();
126126
return AssumeHandles;
127127
}
128128

129129
/// \brief Access the list of assumptions which affect this value.
130-
MutableArrayRef<WeakVH> assumptionsFor(const Value *V) {
130+
MutableArrayRef<WeakTrackingVH> assumptionsFor(const Value *V) {
131131
if (!Scanned)
132132
scanFunction();
133133

134134
auto AVI = AffectedValues.find_as(const_cast<Value *>(V));
135135
if (AVI == AffectedValues.end())
136-
return MutableArrayRef<WeakVH>();
136+
return MutableArrayRef<WeakTrackingVH>();
137137

138138
return AVI->second;
139139
}

llvm/include/llvm/Analysis/CGSCCPassManager.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ class DevirtSCCRepeatedPass
646646
LazyCallGraph::SCC *C = &InitialC;
647647

648648
// Collect value handles for all of the indirect call sites.
649-
SmallVector<WeakVH, 8> CallHandles;
649+
SmallVector<WeakTrackingVH, 8> CallHandles;
650650

651651
// Struct to track the counts of direct and indirect calls in each function
652652
// of the SCC.
@@ -658,7 +658,7 @@ class DevirtSCCRepeatedPass
658658
// Put value handles on all of the indirect calls and return the number of
659659
// direct calls for each function in the SCC.
660660
auto ScanSCC = [](LazyCallGraph::SCC &C,
661-
SmallVectorImpl<WeakVH> &CallHandles) {
661+
SmallVectorImpl<WeakTrackingVH> &CallHandles) {
662662
assert(CallHandles.empty() && "Must start with a clear set of handles.");
663663

664664
SmallVector<CallCount, 4> CallCounts;
@@ -671,7 +671,7 @@ class DevirtSCCRepeatedPass
671671
++Count.Direct;
672672
} else {
673673
++Count.Indirect;
674-
CallHandles.push_back(WeakVH(&I));
674+
CallHandles.push_back(WeakTrackingVH(&I));
675675
}
676676
}
677677
}
@@ -699,7 +699,7 @@ class DevirtSCCRepeatedPass
699699
"Cannot have changed the size of the SCC!");
700700

701701
// Check whether any of the handles were devirtualized.
702-
auto IsDevirtualizedHandle = [&](WeakVH &CallH) {
702+
auto IsDevirtualizedHandle = [&](WeakTrackingVH &CallH) {
703703
if (!CallH)
704704
return false;
705705
auto CS = CallSite(CallH);

llvm/include/llvm/Analysis/CallGraph.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class CallGraphNode {
172172
public:
173173
/// \brief A pair of the calling instruction (a call or invoke)
174174
/// and the call graph node being called.
175-
typedef std::pair<WeakVH, CallGraphNode *> CallRecord;
175+
typedef std::pair<WeakTrackingVH, CallGraphNode *> CallRecord;
176176

177177
public:
178178
typedef std::vector<CallRecord> CalledFunctionsVector;

llvm/include/llvm/Analysis/IVUsers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class IVStrideUse final : public CallbackVH, public ilist_node<IVStrideUse> {
8080

8181
/// OperandValToReplace - The Value of the operand in the user instruction
8282
/// that this IVStrideUse is representing.
83-
WeakVH OperandValToReplace;
83+
WeakTrackingVH OperandValToReplace;
8484

8585
/// PostIncLoops - The set of loops for which Expr has been adjusted to
8686
/// use post-inc mode. This corresponds with SCEVExpander's post-inc concept.

llvm/include/llvm/Analysis/MemoryBuiltins.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class ObjectSizeOffsetEvaluator
235235
: public InstVisitor<ObjectSizeOffsetEvaluator, SizeOffsetEvalType> {
236236

237237
typedef IRBuilder<TargetFolder> BuilderTy;
238-
typedef std::pair<WeakVH, WeakVH> WeakEvalType;
238+
typedef std::pair<WeakTrackingVH, WeakTrackingVH> WeakEvalType;
239239
typedef DenseMap<const Value*, WeakEvalType> CacheMapTy;
240240
typedef SmallPtrSet<const Value*, 8> PtrSetTy;
241241

llvm/include/llvm/Analysis/ScalarEvolutionExpander.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ namespace llvm {
189189
/// replace congruent phis with their most canonical representative. Return
190190
/// the number of phis eliminated.
191191
unsigned replaceCongruentIVs(Loop *L, const DominatorTree *DT,
192-
SmallVectorImpl<WeakVH> &DeadInsts,
192+
SmallVectorImpl<WeakTrackingVH> &DeadInsts,
193193
const TargetTransformInfo *TTI = nullptr);
194194

195195
/// Insert code to directly compute the specified SCEV expression into the

llvm/include/llvm/IR/ValueHandle.h

+19-19
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ class ValueHandleBase {
3434
///
3535
/// This is to avoid having a vtable for the light-weight handle pointers. The
3636
/// fully general Callback version does have a vtable.
37-
enum HandleBaseKind {
38-
Assert,
39-
Callback,
40-
Weak
41-
};
37+
enum HandleBaseKind { Assert, Callback, WeakTracking };
4238

4339
ValueHandleBase(const ValueHandleBase &RHS)
4440
: ValueHandleBase(RHS.PrevPair.getInt(), RHS) {}
@@ -145,14 +141,14 @@ class ValueHandleBase {
145141
/// is useful for advisory sorts of information, but should not be used as the
146142
/// key of a map (since the map would have to rearrange itself when the pointer
147143
/// changes).
148-
class WeakVH : public ValueHandleBase {
144+
class WeakTrackingVH : public ValueHandleBase {
149145
public:
150-
WeakVH() : ValueHandleBase(Weak) {}
151-
WeakVH(Value *P) : ValueHandleBase(Weak, P) {}
152-
WeakVH(const WeakVH &RHS)
153-
: ValueHandleBase(Weak, RHS) {}
146+
WeakTrackingVH() : ValueHandleBase(WeakTracking) {}
147+
WeakTrackingVH(Value *P) : ValueHandleBase(WeakTracking, P) {}
148+
WeakTrackingVH(const WeakTrackingVH &RHS)
149+
: ValueHandleBase(WeakTracking, RHS) {}
154150

155-
WeakVH &operator=(const WeakVH &RHS) = default;
151+
WeakTrackingVH &operator=(const WeakTrackingVH &RHS) = default;
156152

157153
Value *operator=(Value *RHS) {
158154
return ValueHandleBase::operator=(RHS);
@@ -170,15 +166,17 @@ class WeakVH : public ValueHandleBase {
170166
}
171167
};
172168

173-
// Specialize simplify_type to allow WeakVH to participate in
169+
// Specialize simplify_type to allow WeakTrackingVH to participate in
174170
// dyn_cast, isa, etc.
175-
template <> struct simplify_type<WeakVH> {
171+
template <> struct simplify_type<WeakTrackingVH> {
176172
typedef Value *SimpleType;
177-
static SimpleType getSimplifiedValue(WeakVH &WVH) { return WVH; }
173+
static SimpleType getSimplifiedValue(WeakTrackingVH &WVH) { return WVH; }
178174
};
179-
template <> struct simplify_type<const WeakVH> {
175+
template <> struct simplify_type<const WeakTrackingVH> {
180176
typedef Value *SimpleType;
181-
static SimpleType getSimplifiedValue(const WeakVH &WVH) { return WVH; }
177+
static SimpleType getSimplifiedValue(const WeakTrackingVH &WVH) {
178+
return WVH;
179+
}
182180
};
183181

184182
/// \brief Value handle that asserts if the Value is deleted.
@@ -294,7 +292,7 @@ struct isPodLike<AssertingVH<T> > {
294292
/// Assigning a value to a TrackingVH is always allowed, even if said TrackingVH
295293
/// no longer points to a valid value.
296294
template <typename ValueTy> class TrackingVH {
297-
WeakVH InnerHandle;
295+
WeakTrackingVH InnerHandle;
298296

299297
public:
300298
ValueTy *getValPtr() const {
@@ -368,7 +366,8 @@ class CallbackVH : public ValueHandleBase {
368366
///
369367
/// Called when this->getValPtr() is destroyed, inside ~Value(), so you
370368
/// may call any non-virtual Value method on getValPtr(), but no subclass
371-
/// methods. If WeakVH were implemented as a CallbackVH, it would use this
369+
/// methods. If WeakTrackingVH were implemented as a CallbackVH, it would use
370+
/// this
372371
/// method to call setValPtr(NULL). AssertingVH would use this method to
373372
/// cause an assertion failure.
374373
///
@@ -379,7 +378,8 @@ class CallbackVH : public ValueHandleBase {
379378
/// \brief Callback for Value RAUW.
380379
///
381380
/// Called when this->getValPtr()->replaceAllUsesWith(new_value) is called,
382-
/// _before_ any of the uses have actually been replaced. If WeakVH were
381+
/// _before_ any of the uses have actually been replaced. If WeakTrackingVH
382+
/// were
383383
/// implemented as a CallbackVH, it would use this method to call
384384
/// setValPtr(new_value). AssertingVH would do nothing in this method.
385385
virtual void allUsesReplacedWith(Value *) {}

llvm/include/llvm/Transforms/Scalar/NaryReassociate.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class NaryReassociatePass : public PassInfoMixin<NaryReassociatePass> {
167167
// foo(a + b);
168168
// if (p2)
169169
// bar(a + b);
170-
DenseMap<const SCEV *, SmallVector<WeakVH, 2>> SeenExprs;
170+
DenseMap<const SCEV *, SmallVector<WeakTrackingVH, 2>> SeenExprs;
171171
};
172172
} // namespace llvm
173173

llvm/include/llvm/Transforms/Utils/Cloning.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct ClonedCodeInfo {
7474
/// All cloned call sites that have operand bundles attached are appended to
7575
/// this vector. This vector may contain nulls or undefs if some of the
7676
/// originally inserted callsites were DCE'ed after they were cloned.
77-
std::vector<WeakVH> OperandBundleCallSites;
77+
std::vector<WeakTrackingVH> OperandBundleCallSites;
7878

7979
ClonedCodeInfo() = default;
8080
};
@@ -192,7 +192,7 @@ class InlineFunctionInfo {
192192

193193
/// InlinedCalls - InlineFunction fills this in with callsites that were
194194
/// inlined from the callee. This is only filled in if CG is non-null.
195-
SmallVector<WeakVH, 8> InlinedCalls;
195+
SmallVector<WeakTrackingVH, 8> InlinedCalls;
196196

197197
/// All of the new call sites inlined into the caller.
198198
///

llvm/include/llvm/Transforms/Utils/SimplifyIndVar.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ class IVVisitor {
4646
/// simplifyUsersOfIV - Simplify instructions that use this induction variable
4747
/// by using ScalarEvolution to analyze the IV's recurrence.
4848
bool simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, DominatorTree *DT,
49-
LoopInfo *LI, SmallVectorImpl<WeakVH> &Dead,
49+
LoopInfo *LI, SmallVectorImpl<WeakTrackingVH> &Dead,
5050
IVVisitor *V = nullptr);
5151

5252
/// SimplifyLoopIVs - Simplify users of induction variables within this
5353
/// loop. This does not actually change or add IVs.
5454
bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, DominatorTree *DT,
55-
LoopInfo *LI, SmallVectorImpl<WeakVH> &Dead);
55+
LoopInfo *LI, SmallVectorImpl<WeakTrackingVH> &Dead);
5656

5757
} // end namespace llvm
5858

llvm/include/llvm/Transforms/Utils/ValueMapper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace llvm {
2323

2424
class Value;
2525
class Instruction;
26-
typedef ValueMap<const Value *, WeakVH> ValueToValueMapTy;
26+
typedef ValueMap<const Value *, WeakTrackingVH> ValueToValueMapTy;
2727

2828
/// This is a class that can be implemented by clients to remap types when
2929
/// cloning constants and instructions.

llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class BoUpSLP;
4040
struct SLPVectorizerPass : public PassInfoMixin<SLPVectorizerPass> {
4141
typedef SmallVector<StoreInst *, 8> StoreList;
4242
typedef MapVector<Value *, StoreList> StoreListMap;
43-
typedef SmallVector<WeakVH, 8> WeakVHList;
44-
typedef MapVector<Value *, WeakVHList> WeakVHListMap;
43+
typedef SmallVector<WeakTrackingVH, 8> WeakTrackingVHList;
44+
typedef MapVector<Value *, WeakTrackingVHList> WeakTrackingVHListMap;
4545

4646
ScalarEvolution *SE = nullptr;
4747
TargetTransformInfo *TTI = nullptr;
@@ -111,7 +111,7 @@ struct SLPVectorizerPass : public PassInfoMixin<SLPVectorizerPass> {
111111
StoreListMap Stores;
112112

113113
/// The getelementptr instructions in a basic block organized by base pointer.
114-
WeakVHListMap GEPs;
114+
WeakTrackingVHListMap GEPs;
115115
};
116116
}
117117

llvm/lib/Analysis/AssumptionCache.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ static cl::opt<bool>
2929
cl::desc("Enable verification of assumption cache"),
3030
cl::init(false));
3131

32-
SmallVector<WeakVH, 1> &AssumptionCache::getOrInsertAffectedValues(Value *V) {
32+
SmallVector<WeakTrackingVH, 1> &
33+
AssumptionCache::getOrInsertAffectedValues(Value *V) {
3334
// Try using find_as first to avoid creating extra value handles just for the
3435
// purpose of doing the lookup.
3536
auto AVI = AffectedValues.find_as(V);
3637
if (AVI != AffectedValues.end())
3738
return AVI->second;
3839

39-
auto AVIP = AffectedValues.insert({
40-
AffectedValueCallbackVH(V, this), SmallVector<WeakVH, 1>()});
40+
auto AVIP = AffectedValues.insert(
41+
{AffectedValueCallbackVH(V, this), SmallVector<WeakTrackingVH, 1>()});
4142
return AVIP.first->second;
4243
}
4344

llvm/lib/Analysis/CallGraphSCCPass.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ bool CGPassManager::RefreshCallGraph(const CallGraphSCC &CurSCC, CallGraph &CG,
204204
// Get the set of call sites currently in the function.
205205
for (CallGraphNode::iterator I = CGN->begin(), E = CGN->end(); I != E; ) {
206206
// If this call site is null, then the function pass deleted the call
207-
// entirely and the WeakVH nulled it out.
207+
// entirely and the WeakTrackingVH nulled it out.
208208
if (!I->first ||
209209
// If we've already seen this call site, then the FunctionPass RAUW'd
210210
// one call with another, which resulted in two "uses" in the edge
@@ -347,7 +347,8 @@ bool CGPassManager::RefreshCallGraph(const CallGraphSCC &CurSCC, CallGraph &CG,
347347
DevirtualizedCall = true;
348348

349349
// After scanning this function, if we still have entries in callsites, then
350-
// they are dangling pointers. WeakVH should save us for this, so abort if
350+
// they are dangling pointers. WeakTrackingVH should save us for this, so
351+
// abort if
351352
// this happens.
352353
assert(CallSites.empty() && "Dangling pointers found in call sites map");
353354

llvm/lib/Analysis/ScalarEvolutionExpander.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1772,9 +1772,10 @@ SCEVExpander::getOrInsertCanonicalInductionVariable(const Loop *L,
17721772
///
17731773
/// This does not depend on any SCEVExpander state but should be used in
17741774
/// the same context that SCEVExpander is used.
1775-
unsigned SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
1776-
SmallVectorImpl<WeakVH> &DeadInsts,
1777-
const TargetTransformInfo *TTI) {
1775+
unsigned
1776+
SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
1777+
SmallVectorImpl<WeakTrackingVH> &DeadInsts,
1778+
const TargetTransformInfo *TTI) {
17781779
// Find integer phis in order of increasing width.
17791780
SmallVector<PHINode*, 8> Phis;
17801781
for (auto &I : *L->getHeader()) {

llvm/lib/Bitcode/Reader/ValueList.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void BitcodeReaderValueList::assignValue(Value *V, unsigned Idx) {
5858
if (Idx >= size())
5959
resize(Idx + 1);
6060

61-
WeakVH &OldV = ValuePtrs[Idx];
61+
WeakTrackingVH &OldV = ValuePtrs[Idx];
6262
if (!OldV) {
6363
OldV = V;
6464
return;

llvm/lib/Bitcode/Reader/ValueList.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace llvm {
2020
class Constant;
2121

2222
class BitcodeReaderValueList {
23-
std::vector<WeakVH> ValuePtrs;
23+
std::vector<WeakTrackingVH> ValuePtrs;
2424

2525
/// As we resolve forward-referenced constants, we add information about them
2626
/// to this vector. This allows us to resolve them in bulk instead of

llvm/lib/CodeGen/CodeGenPrepare.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -2226,10 +2226,11 @@ bool CodeGenPrepare::optimizeCallInst(CallInst *CI, bool& ModifiedDT) {
22262226
ConstantInt *RetVal =
22272227
lowerObjectSizeCall(II, *DL, TLInfo, /*MustSucceed=*/true);
22282228
// Substituting this can cause recursive simplifications, which can
2229-
// invalidate our iterator. Use a WeakVH to hold onto it in case this
2229+
// invalidate our iterator. Use a WeakTrackingVH to hold onto it in case
2230+
// this
22302231
// happens.
22312232
Value *CurValue = &*CurInstIterator;
2232-
WeakVH IterHandle(CurValue);
2233+
WeakTrackingVH IterHandle(CurValue);
22332234

22342235
replaceAndRecursivelySimplify(CI, RetVal, TLInfo, nullptr);
22352236

@@ -4442,9 +4443,9 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
44424443
// using it.
44434444
if (Repl->use_empty()) {
44444445
// This can cause recursive deletion, which can invalidate our iterator.
4445-
// Use a WeakVH to hold onto it in case this happens.
4446+
// Use a WeakTrackingVH to hold onto it in case this happens.
44464447
Value *CurValue = &*CurInstIterator;
4447-
WeakVH IterHandle(CurValue);
4448+
WeakTrackingVH IterHandle(CurValue);
44484449
BasicBlock *BB = CurInstIterator->getParent();
44494450

44504451
RecursivelyDeleteTriviallyDeadInstructions(Repl, TLInfo);

0 commit comments

Comments
 (0)