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 › docs › OpaquePointers.html
Opaque Pointers — LLVM 23.0.0git documentation
In order to support opaque pointers, two types of changes tend to be necessary. The first is the removal of all calls to PointerType::getElementType() and Type::getPointerElementType(). In the LLVM middle-end and backend, this is usually accomplished by inspecting the type of relevant operations ...
Discussions

c++ - I am getting a pointer type error on llvm - Stack Overflow
I am getting this error while trying to run my C++ program: error: 'class llvm::PointerType' has no member named 'getPointerElementType'; did you mean 'getStructElementType'? 551 | auto More on stackoverflow.com
🌐 stackoverflow.com
Typed pointers support will be dropped in LLVM 17
Hi guys, In Espressif we are trying to use GLOW for our chips. During porting our LLVM fork to support glow we faced a problem. There are a lot of uses of getPointerElementType in your code base wh... More on github.com
🌐 github.com
2
February 1, 2023
Get pointee type from an opaque pointer type in function argument - Loop Optimizations - LLVM Discussion Forums
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 ... More on discourse.llvm.org
🌐 discourse.llvm.org
1
November 7, 2022
`getelementptr` using a vector of pointers
LLVM allows using getelementptr with Vector indices, from LLVM 10 LangRef: ; Add distinct offsets to the same pointer: ; A[i] = ptr + offsets[i]*sizeof(i8) %A = getelementptr i8, i8* %ptr, %offsets However llvmlite doesn't seem... More on github.com
🌐 github.com
1
July 28, 2021
🌐
Hdoc
docs.hdoc.io › hdoc › llvm-project › r4C0FBD0A3419362A.html
class Type: LLVM/Clang 15.x documentation
public llvm::Type * getPointerElementType() const · public llvm::PointerType * getPointerTo(unsigned int AddrSpace = 0) const · public llvm::TypeSize getPrimitiveSizeInBits() const · public static llvm::Type * getPrimitiveType(llvm::LLVMContext & C, llvm::Type::TypeID IDNumber) public unsigned int getScalarSizeInBits() const ·
🌐
LLVM
reviews.llvm.org › D117885
⚙ D117885 [OpaquePtrs] Deprecate PointerType::getElementType()
This deprecates PointerType::getElementType() in favor of Type::getPointerElementType(). The motivation is to make it more apparent when code accesses the pointer element type, because getElementType() may also also refer to at least ArrayType::getElementType() and VectorType::getElementType() ...
🌐
LLVM
llvm.org › doxygen › classllvm_1_1Type.html
LLVM: llvm::Type Class Reference
Based on this value, you can cast to a class defined in DerivedTypes.h. Note: If you add an element to this, you need to add an element to the Type::getPrimitiveType function, or else things will break! Also update LLVMTypeKind and LLVMGetTypeKind () in the C binding.
🌐
LLVM
llvm.org › doxygen › classllvm_1_1GetElementPtrInst.html
LLVM: llvm::GetElementPtrInst Class Reference
an instruction for type-safe pointer arithmetic to access elements of arrays and structs More · an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Find elsewhere
🌐
AMD ROCm
rocm.docs.amd.com › projects › llvm-project › en › latest › LLVM › llvm › html › OpaquePointers.html
Opaque Pointers — LLVM 22.0.0git documentation
In order to support opaque pointers, two types of changes tend to be necessary. The first is the removal of all calls to PointerType::getElementType() and Type::getPointerElementType(). In the LLVM middle-end and backend, this is usually accomplished by inspecting the type of relevant operations ...
🌐
Google Groups
groups.google.com › g › llvm-dev › c › jc9_IUM37DA
[llvm-dev] Opaque Pointers Help Wanted
(Looks like the page hasn't been rebuilt in a while, https://github.com/llvm/llvm-project/blob/main/llvm/docs/OpaquePointers.rst#transition-plan contains some more concrete steps) Essentially almost all of the work boils down to figuring out how to remove calls to `PointerType::getElementType()` and `Type::getPointerElementType()`. Everything else derives from that.
🌐
Stack Overflow
stackoverflow.com › questions › 79573452 › i-am-getting-a-pointer-type-error-on-llvm
c++ - I am getting a pointer type error on llvm - Stack Overflow
error: 'class llvm::PointerType' has no member named 'getPointerElementType'; did you mean 'getStructElementType'? 551 | auto dataType = ptrType->getPointerElementType(); | ^~~~~~~~~~~~~~~~~~~~~ | getStructElementType
🌐
LLVM
releases.llvm.org › 14.0.0 › docs › OpaquePointers.html
Opaque Pointers — LLVM 14.0.0 documentation
March 25, 2022 - If you have use cases that this sort of fix doesn’t cover, please email llvm-dev. In order to support opaque pointers, two types of changes tend to be necessary. The first is the removal of all calls to PointerType::getElementType() and Type::getPointerElementType().
🌐
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. ... 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 remain unchanged and are used as before for differentiating pointer types relevant to architecture-specific lowering. ... Removal of Functions: Functions like PointerType::getElementType() and Type::getPointerElementType() are deprecated.
🌐
GitHub
github.com › pytorch › glow › issues › 6053
Typed pointers support will be dropped in LLVM 17 · Issue #6053 · pytorch/glow
February 1, 2023 - During porting our LLVM fork to support glow we faced a problem. There are a lot of uses of getPointerElementType in your code base what conflicts with LLVM opaque pointers mode feature. Staring from LLVM 15 that mode is the default, so we had to disable it in our Glow port manually.
Author   pytorch
🌐
Yossarian.net
blog.yossarian.net › 2020 › 09 › 19 › LLVMs-getelementptr-by-example
LLVM's getelementptr, by example - ENOSUCHBLOG
September 19, 2020 - Nonetheless, my eyes still swim whenever I actually read a getelementptr in real IR. LLVM’s developers are aware of how confusing getelementptr is: they have an entire separate page dedicated to explaining its syntax, why it doesn’t touch memory, and the various constraints on constructing a valid one.
🌐
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 ...
🌐
Clang
clang.llvm.org › doxygen › classclang_1_1PointerType.html
clang: clang::PointerType Class Reference
PointerType - C99 6.7.5.1 - Pointer Declarators. More · PointerType - C99 6.7.5.1 - Pointer Declarators
🌐
GitHub
github.com › iovisor › bpftrace › issues › 2365
bpftrace segfaults when using llvm-15 "Attempting to get element type of opaque pointer" · Issue #2365 · bpftrace/bpftrace
September 23, 2022 - INTERNAL_SYSCALL_ERRNO (ret) : 0; (gdb) bt #0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44 #1 0x00007fffeeab0d33 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78 #2 0x00007fffeea60aa6 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #3 0x00007fffeea4a7fc in __GI_abort () at abort.c:79 #4 0x00007fffeea4a71b in __assert_fail_base (fmt=0x7fffeebbe9c0 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x784e40 "NumContainedTys && \"Attempting to get element type of opaq
Author   bpftrace
🌐
LLVM
llvm.org › docs › GetElementPtr.html
The Often Misunderstood GEP Instruction — LLVM 23.0.0git documentation
This document seeks to dispel the mystery and confusion surrounding LLVM’s GetElementPtr (GEP) instruction. Questions about the wily GEP instruction are probably the most frequent questions once a developer gets down to coding with LLVM.
🌐
GitHub
github.com › numba › llvmlite › issues › 756
`getelementptr` using a vector of pointers · Issue #756 · numba/llvmlite
July 28, 2021 - LLVM allows using getelementptr with Vector indices, from LLVM 10 LangRef: ; Add distinct offsets to the same pointer: ; A[i] = ptr + offsets[i]*sizeof(i8) %A = getelementptr i8, i8* %ptr, %offsets However llvmlite doesn't seem...
Author   numba