Skip to content

Commit 45018c7

Browse files
Rename WeakVH to WeakTrackingVH; NFC (microsoft#6663)
This PR pulls the upstream change, Rename WeakVH to WeakTrackingVH; NFC (llvm/llvm-project@e6bca0e), into DXC. Here's the summary of the change: > I plan to use WeakVH to mean "nulls itself out on deletion, but does not track RAUW" in a subsequent commit. > > Reviewers: dblaikie, davide > > Reviewed By: davide > > Subscribers: arsenm, mehdi_amini, mcrosier, mzolotukhin, jfb, llvm-commits, nhaehnle > > Differential Revision: https://reviews.llvm.org/D32266 This is part 3 of the fix for microsoft#6659. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent df87613 commit 45018c7

38 files changed

+170
-178
lines changed

docs/ProgrammersManual.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,9 +1416,9 @@ llvm/IR/ValueMap.h
14161416
ValueMap is a wrapper around a :ref:`DenseMap <dss_densemap>` mapping
14171417
``Value*``\ s (or subclasses) to another type. When a Value is deleted or
14181418
RAUW'ed, ValueMap will update itself so the new version of the key is mapped to
1419-
the same value, just as if the key were a WeakVH. You can configure exactly how
1420-
this happens, and what else happens on these two events, by passing a ``Config``
1421-
parameter to the ValueMap template.
1419+
the same value, just as if the key were a WeakTrackingVH. You can configure
1420+
exactly how this happens, and what else happens on these two events, by passing
1421+
a ``Config`` parameter to the ValueMap template.
14221422

14231423
.. _dss_intervalmap:
14241424

include/llvm/Analysis/AssumptionCache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class AssumptionCache {
4848

4949
/// \brief Vector of weak value handles to calls of the @llvm.assume
5050
/// intrinsic.
51-
SmallVector<WeakVH, 4> AssumeHandles;
51+
SmallVector<WeakTrackingVH, 4> AssumeHandles;
5252

5353
/// \brief Flag tracking whether we have scanned the function yet.
5454
///
@@ -86,7 +86,7 @@ class AssumptionCache {
8686
/// FIXME: We should replace this with pointee_iterator<filter_iterator<...>>
8787
/// when we can write that to filter out the null values. Then caller code
8888
/// will become simpler.
89-
MutableArrayRef<WeakVH> assumptions() {
89+
MutableArrayRef<WeakTrackingVH> assumptions() {
9090
if (!Scanned)
9191
scanFunction();
9292
return AssumeHandles;

include/llvm/Analysis/CallGraph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class CallGraphNode {
169169
public:
170170
/// \brief A pair of the calling instruction (a call or invoke)
171171
/// and the call graph node being called.
172-
typedef std::pair<WeakVH, CallGraphNode *> CallRecord;
172+
typedef std::pair<WeakTrackingVH, CallGraphNode *> CallRecord;
173173

174174
public:
175175
typedef std::vector<CallRecord> CalledFunctionsVector;

include/llvm/Analysis/DxilValueCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct DxilValueCache : public ImmutablePass {
3131
void allUsesReplacedWith(Value *) override { setValPtr(nullptr); }
3232
};
3333
struct ValueEntry {
34-
WeakVH Value;
34+
WeakTrackingVH Value;
3535
ValueVH Self;
3636
ValueEntry() : Value(nullptr), Self(nullptr) {}
3737
inline void Set(llvm::Value *Key, llvm::Value *V) {

include/llvm/Analysis/IVUsers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class IVStrideUse : public CallbackVH, public ilist_node<IVStrideUse> {
7979

8080
/// OperandValToReplace - The Value of the operand in the user instruction
8181
/// that this IVStrideUse is representing.
82-
WeakVH OperandValToReplace;
82+
WeakTrackingVH OperandValToReplace;
8383

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

include/llvm/Analysis/MemoryBuiltins.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class ObjectSizeOffsetEvaluator
208208
: public InstVisitor<ObjectSizeOffsetEvaluator, SizeOffsetEvalType> {
209209

210210
typedef IRBuilder<true, TargetFolder> BuilderTy;
211-
typedef std::pair<WeakVH, WeakVH> WeakEvalType;
211+
typedef std::pair<WeakTrackingVH, WeakTrackingVH> WeakEvalType;
212212
typedef DenseMap<const Value*, WeakEvalType> CacheMapTy;
213213
typedef SmallPtrSet<const Value*, 8> PtrSetTy;
214214

include/llvm/Analysis/ScalarEvolutionExpander.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ namespace llvm {
138138
/// \brief replace congruent phis with their most canonical
139139
/// representative. Return the number of phis eliminated.
140140
unsigned replaceCongruentIVs(Loop *L, const DominatorTree *DT,
141-
SmallVectorImpl<WeakVH> &DeadInsts,
141+
SmallVectorImpl<WeakTrackingVH> &DeadInsts,
142142
const TargetTransformInfo *TTI = nullptr);
143143

144144
/// \brief Insert code to directly compute the specified SCEV expression

include/llvm/IR/ValueHandle.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ValueHandleBase {
4545
///
4646
/// This is to avoid having a vtable for the light-weight handle pointers. The
4747
/// fully general Callback version does have a vtable.
48-
enum HandleBaseKind { Assert, Callback, Weak };
48+
enum HandleBaseKind { Assert, Callback, WeakTracking };
4949

5050
private:
5151
PointerIntPair<ValueHandleBase**, 2, HandleBaseKind> PrevPair;
@@ -141,14 +141,14 @@ class ValueHandleBase {
141141
/// is useful for advisory sorts of information, but should not be used as the
142142
/// key of a map (since the map would have to rearrange itself when the pointer
143143
/// changes).
144-
class WeakVH : public ValueHandleBase {
144+
class WeakTrackingVH : public ValueHandleBase {
145145
public:
146-
WeakVH() : ValueHandleBase(Weak) {}
147-
WeakVH(Value *P) : ValueHandleBase(Weak, P) {}
148-
WeakVH(const WeakVH &RHS)
149-
: ValueHandleBase(Weak, RHS) {}
146+
WeakTrackingVH() : ValueHandleBase(WeakTracking) {}
147+
WeakTrackingVH(Value *P) : ValueHandleBase(WeakTracking, P) {}
148+
WeakTrackingVH(const WeakTrackingVH &RHS)
149+
: ValueHandleBase(WeakTracking, RHS) {}
150150

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

153153
Value *operator=(Value *RHS) {
154154
return ValueHandleBase::operator=(RHS);
@@ -166,15 +166,17 @@ class WeakVH : public ValueHandleBase {
166166
}
167167
};
168168

169-
// Specialize simplify_type to allow WeakVH to participate in
169+
// Specialize simplify_type to allow WeakTrackingVH to participate in
170170
// dyn_cast, isa, etc.
171-
template <> struct simplify_type<WeakVH> {
171+
template <> struct simplify_type<WeakTrackingVH> {
172172
typedef Value *SimpleType;
173-
static SimpleType getSimplifiedValue(WeakVH &WVH) { return WVH; }
173+
static SimpleType getSimplifiedValue(WeakTrackingVH &WVH) { return WVH; }
174174
};
175-
template <> struct simplify_type<const WeakVH> {
175+
template <> struct simplify_type<const WeakTrackingVH> {
176176
typedef Value *SimpleType;
177-
static SimpleType getSimplifiedValue(const WeakVH &WVH) { return WVH; }
177+
static SimpleType getSimplifiedValue(const WeakTrackingVH &WVH) {
178+
return WVH;
179+
}
178180
};
179181

180182
/// \brief Value handle that asserts if the Value is deleted.
@@ -291,7 +293,7 @@ struct isPodLike<AssertingVH<T> > {
291293
/// Assigning a value to a TrackingVH is always allowed, even if said TrackingVH
292294
/// no longer points to a valid value.
293295
template <typename ValueTy> class TrackingVH {
294-
WeakVH InnerHandle;
296+
WeakTrackingVH InnerHandle;
295297

296298
public:
297299
ValueTy *getValPtr() const {
@@ -396,7 +398,8 @@ class CallbackVH : public ValueHandleBase {
396398
///
397399
/// Called when this->getValPtr() is destroyed, inside ~Value(), so you
398400
/// may call any non-virtual Value method on getValPtr(), but no subclass
399-
/// methods. If WeakVH were implemented as a CallbackVH, it would use this
401+
/// methods. If WeakTrackingVH were implemented as a CallbackVH, it would use
402+
/// this
400403
/// method to call setValPtr(NULL). AssertingVH would use this method to
401404
/// cause an assertion failure.
402405
///
@@ -407,7 +410,8 @@ class CallbackVH : public ValueHandleBase {
407410
/// \brief Callback for Value RAUW.
408411
///
409412
/// Called when this->getValPtr()->replaceAllUsesWith(new_value) is called,
410-
/// _before_ any of the uses have actually been replaced. If WeakVH were
413+
/// _before_ any of the uses have actually been replaced. If WeakTrackingVH
414+
/// were
411415
/// implemented as a CallbackVH, it would use this method to call
412416
/// setValPtr(new_value). AssertingVH would do nothing in this method.
413417
virtual void allUsesReplacedWith(Value *) {}

include/llvm/Transforms/Utils/Cloning.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class InlineFunctionInfo {
209209

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

214214
void reset() {
215215
StaticAllocas.clear();

include/llvm/Transforms/Utils/SimplifyIndVar.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ class IVVisitor {
5858
/// simplifyUsersOfIV - Simplify instructions that use this induction variable
5959
/// by using ScalarEvolution to analyze the IV's recurrence.
6060
bool simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, LPPassManager *LPM,
61-
SmallVectorImpl<WeakVH> &Dead, IVVisitor *V = nullptr);
61+
SmallVectorImpl<WeakTrackingVH> &Dead,
62+
IVVisitor *V = nullptr);
6263

6364
/// SimplifyLoopIVs - Simplify users of induction variables within this
6465
/// loop. This does not actually change or add IVs.
6566
bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, LPPassManager *LPM,
66-
SmallVectorImpl<WeakVH> &Dead);
67+
SmallVectorImpl<WeakTrackingVH> &Dead);
6768

6869
} // namespace llvm
6970

0 commit comments

Comments
 (0)