Skip to content

Commit 205270e

Browse files
committed
[PtrUseVisitor] Allow using Argument as a starting point
Argument is another possible starting point for the pointer traversal, and PtrUseVisitor should be able to handle it.
1 parent f999b32 commit 205270e

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
@@ -158,7 +158,7 @@ class PtrUseVisitorBase {
158158
///
159159
/// This will visit the users with the same offset of the current visit
160160
/// (including an unknown offset if that is the current state).
161-
void enqueueUsers(Instruction &I);
161+
void enqueueUsers(Value &I);
162162

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

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