Skip to content

Commit 688a274

Browse files
authored
[PtrUseVisitor] Allow using Argument as a starting point (#106308)
Argument is another possible starting point for the pointer traversal, and PtrUseVisitor should be able to handle it.
1 parent 8a267b7 commit 688a274

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

llvm/include/llvm/Analysis/PtrUseVisitor.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class PtrUseVisitorBase {
157157
///
158158
/// This will visit the users with the same offset of the current visit
159159
/// (including an unknown offset if that is the current state).
160-
void enqueueUsers(Instruction &I);
160+
void enqueueUsers(Value &I);
161161

162162
/// Walk the operands of a GEP and adjust the offset as appropriate.
163163
///
@@ -208,11 +208,14 @@ class PtrUseVisitor : protected InstVisitor<DerivedT>,
208208

209209
/// Recursively visit the uses of the given pointer.
210210
/// \returns An info struct about the pointer. See \c PtrInfo for details.
211-
PtrInfo visitPtr(Instruction &I) {
211+
/// We may also need to process Argument pointers, so the input uses is
212+
/// a common Value type.
213+
PtrInfo visitPtr(Value &I) {
212214
// This must be a pointer type. Get an integer type suitable to hold
213215
// offsets on this pointer.
214216
// FIXME: Support a vector of pointers.
215217
assert(I.getType()->isPointerTy());
218+
assert(isa<Instruction>(I) || isa<Argument>(I));
216219
IntegerType *IntIdxTy = cast<IntegerType>(DL.getIndexType(I.getType()));
217220
IsOffsetKnown = true;
218221
Offset = APInt(IntIdxTy->getBitWidth(), 0);

llvm/lib/Analysis/PtrUseVisitor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
using namespace llvm;
1919

20-
void detail::PtrUseVisitorBase::enqueueUsers(Instruction &I) {
20+
void detail::PtrUseVisitorBase::enqueueUsers(Value &I) {
2121
for (Use &U : I.uses()) {
2222
if (VisitedUses.insert(&U).second) {
2323
UseToVisit NewU = {

0 commit comments

Comments
 (0)