First you access an operand you are interested in with instruction->getOperand(i) and then call ->getType() on it. The llvm::Type class has a lot of helper classes and ->isPointerTy() is what you are probably interested in.

Answer from arrowd on Stack Overflow
🌐
LLVM
llvm.org › doxygen › classllvm_1_1PointerType.html
LLVM: llvm::PointerType Class Reference
llvm · PointerType · Public Member Functions | Static Public Member Functions | List of all members · llvm::PointerType Class Reference · Class to represent pointers. More... #include "llvm/IR/DerivedTypes.h" Inheritance diagram for llvm::PointerType: [legend] Class to represent pointers.
🌐
Hdoc
docs.hdoc.io › hdoc › llvm-project › r8B66BCD6672AE2B1.html
class PointerType: LLVM/Clang 15.x documentation
public static llvm::PointerType * getWithSamePointeeType(llvm::PointerType * PT, unsigned int AddressSpace)
🌐
LLVM
llvm.org › doxygen › classPointerType.html
LLVM: PointerType Class Reference
PointerType Class Referencefinal · #include "llvm/Demangle/ItaniumDemangle.h" Inheritance diagram for PointerType: [legend] Definition at line 639 of file ItaniumDemangle.h. Definition at line 643 of file ItaniumDemangle.h. References Node::getRHSComponentCache(), and Node::Node().
🌐
LLVM
llvm.org › docs › OpaquePointers.html
Opaque Pointers — LLVM 23.0.0git documentation
To create a pointer type in a different address space, use PointerType::getWithSamePointeeType().
🌐
GitHub
github.com › llvm › llvm-project › issues › 123569
Remove PointerType::get/getUnqual with element type argument · Issue #123569 · llvm/llvm-project
January 20, 2025 - llvm-project/llvm/include/llvm/IR/DerivedTypes.h · Lines 677 to 679 in 6f0a627 · /// This constructs a pointer to an object of the specified type in a numbered · /// address space. static PointerType *get(Type *ElementType, unsigned AddressSpace); llvm-project/llvm/include/llvm/IR/DerivedTypes.h ·
Author   llvm
🌐
Utoronto
legup.eecg.utoronto.ca › doxygen › classllvm_1_1PointerType.html
LLVM: LLVM: llvm::PointerType Class Reference
References llvm::Type::getTypeID(), and llvm::Type::PointerTyID. Definition at line 548 of file DerivedTypes.h. PointerType::get - This constructs a pointer to an object of the specified type in a numbered address space. Definition at line 1020 of file Type.cpp.
🌐
LLVM
llvm.org › doxygen › classllvm_1_1Type.html
LLVM: llvm::Type Class Reference
Referenced by llvm::PointerType::getAddressSpace(), llvm::TypedPointerType::getAddressSpace(), llvm::ByteType::getBitWidth(), llvm::IntegerType::getBitWidth(), llvm::TargetExtType::getNumIntParameters(), llvm::StructType::isLiteral(), llvm::StructType::isOpaque(), llvm::StructType::isPacked(), llvm::FunctionType::isVarArg(), and setSubclassData().
Find elsewhere
🌐
Utoronto
legup.eecg.utoronto.ca › doxygen-4.0 › classllvm_1_1PointerType.html
LLVM: llvm::PointerType Class Reference
PointerType - Class to represent pointers. Definition at line 445 of file DerivedTypes.h. Implement support type inquiry through isa, cast, and dyn_cast. Definition at line 468 of file DerivedTypes.h. References llvm::Type::getTypeID(), and llvm::Type::PointerTyID.
🌐
Stack Overflow
stackoverflow.com › questions › 32893903 › llvm-api-pointer-type-support
c - LLVM API pointer type support - Stack Overflow
$$ = LLVMBuildStore(Builder,(LLVMConstPointerNull(LLVMInt32TypeInContext(Context))),$1); and this is the error that I am getting::typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::PointerType; Y = llvm::Type; typename llvm::cast_retty<X, Y*>::ret_type = llvm::PointerType*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
🌐
Google Groups
groups.google.com › g › llvm-dev › c › OFH6AStSaWQ › m › CD5r_28YBAAJ
[llvm-dev] [RFC] Introducing the opaque pointer type
While there's been lots of work ... within LLVM so we can start playing around with the opaque pointer type and see what goes wrong. Much of the patch above is based on TNorthover's branch from a couple years ago [2]. The opaque pointer type is essentially just a PointerType with a null ...
🌐
LLVM
llvm.org › doxygen › structllvm_1_1isa__impl_3_01PointerType_00_01Type_01_4.html
LLVM: llvm::isa_impl< PointerType, Type > Struct Reference
llvm · isa_impl< PointerType, Type > Static Public Member Functions | List of all members · llvm::isa_impl< PointerType, Type > Struct Reference · #include "llvm/IR/Type.h" Inheritance diagram for llvm::isa_impl< PointerType, Type >: [legend] Definition at line 542 of file Type.h.
🌐
Matthewbdwyer
matthewbdwyer.github.io › tipc › md_OpaquePointers.html
tipc: Quick summary of Opaque Pointers and how that affects TIPC.
This change is driven by the need to address issues related to the complexity and limitations of explicit pointee types in LLVM's optimization processes and the challenges they pose to frontends and LLVM passes. Opaque Pointer Type: Replaces explicit pointee types (e.g., i32*) with a generic ptr type. Instructions now include type arguments directly (e.g., load i64, ptr p instead of load i64* p). Address Spaces: Address spaces remain unchanged and are used as before for differentiating pointer types relevant to architecture-specific lowering. Migration Instructions: Removal of Functions: Functions like PointerType::getElementType() and Type::getPointerElementType() are deprecated.
🌐
GitHub
github.com › golang › go › issues › 56092
gollvm: error: ‘class llvm::PointerType’ has no member named ‘getElementType’ · Issue #56092 · golang/go
October 6, 2022 - Found out that llvm commit ff040eca93fb5700b30fc81cde9b8f9401c8da67 removed the PointerType::getElementType() function.
Author   golang
🌐
LLVM
llvm.org › doxygen › classllvm_1_1DataLayout.html
LLVM: llvm::DataLayout Class Reference
References llvm::PointerType::get(). Returns a byte type with the same size of a pointer in the given address space. Definition at line 1012 of file DataLayout.cpp. References llvm::CallingConv::C, llvm::ByteType::get(), and getPointerSizeInBits(). Returns a byte (vector of byte) type with ...
🌐
LLVM
llvm.org › doxygen › classllvm_1_1ConstantPointerNull.html
LLVM: llvm::ConstantPointerNull Class Reference
Referenced by addEmuTlsVar(), ... llvm::UpgradeGlobalVariable(), llvm::UpgradeIntrinsicCall(), and llvm::InstCombinerImpl::visitCallInst(). Specialize the getType() method to always return an PointerType, which reduces the amount of casting needed in parts of the ...
🌐
LLVM Discussion Forums
discourse.llvm.org › ir & optimizations › loop optimizations
Get pointee type from an opaque pointer type in function argument - Loop Optimizations - LLVM Discussion Forums
November 7, 2022 - Hi, I need to get pointee type for a function argument: void test(int arr[], int n) { ... } Here, the first argument has an opaque pointer type, but how can I get pointee type for it (i.e. i32)? Opaque pointers have PointeeTy set to nullptr. In this article Opaque Pointers — LLVM 16.0.0git ...