[llvm] 688a274 - [PtrUseVisitor] Allow using Argument as a starting point (#106308)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 30 11:47:36 PDT 2024
Author: Artem Belevich
Date: 2024-08-30T11:47:34-07:00
New Revision: 688a27496d73881a9e793a61f3f3a879f7efd581
URL: https://github.com/llvm/llvm-project/commit/688a27496d73881a9e793a61f3f3a879f7efd581
DIFF: https://github.com/llvm/llvm-project/commit/688a27496d73881a9e793a61f3f3a879f7efd581.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/Analysis/PtrUseVisitor.h
llvm/lib/Analysis/PtrUseVisitor.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/PtrUseVisitor.h b/llvm/include/llvm/Analysis/PtrUseVisitor.h
index f5c23b1b4e014d..237d328721609b 100644
--- a/llvm/include/llvm/Analysis/PtrUseVisitor.h
+++ b/llvm/include/llvm/Analysis/PtrUseVisitor.h
@@ -157,7 +157,7 @@ class PtrUseVisitorBase {
///
/// This will visit the users with the same offset of the current visit
/// (including an unknown offset if that is the current state).
- void enqueueUsers(Instruction &I);
+ void enqueueUsers(Value &I);
/// Walk the operands of a GEP and adjust the offset as appropriate.
///
@@ -208,11 +208,14 @@ class PtrUseVisitor : protected InstVisitor<DerivedT>,
/// Recursively visit the uses of the given pointer.
/// \returns An info struct about the pointer. See \c PtrInfo for details.
- PtrInfo visitPtr(Instruction &I) {
+ /// We may also need to process Argument pointers, so the input uses is
+ /// a common Value type.
+ PtrInfo visitPtr(Value &I) {
// This must be a pointer type. Get an integer type suitable to hold
// offsets on this pointer.
// FIXME: Support a vector of pointers.
assert(I.getType()->isPointerTy());
+ assert(isa<Instruction>(I) || isa<Argument>(I));
IntegerType *IntIdxTy = cast<IntegerType>(DL.getIndexType(I.getType()));
IsOffsetKnown = true;
Offset = APInt(IntIdxTy->getBitWidth(), 0);
diff --git a/llvm/lib/Analysis/PtrUseVisitor.cpp b/llvm/lib/Analysis/PtrUseVisitor.cpp
index 49304818d7efed..9c79546f491eff 100644
--- a/llvm/lib/Analysis/PtrUseVisitor.cpp
+++ b/llvm/lib/Analysis/PtrUseVisitor.cpp
@@ -17,7 +17,7 @@
using namespace llvm;
-void detail::PtrUseVisitorBase::enqueueUsers(Instruction &I) {
+void detail::PtrUseVisitorBase::enqueueUsers(Value &I) {
for (Use &U : I.uses()) {
if (VisitedUses.insert(&U).second) {
UseToVisit NewU = {
More information about the llvm-commits
mailing list