clangllvmllvm-ir

How to get pointer level in LLVM 17 with opaque pointer enabled?


According to llvm opaque pointer documentation, only opaque pointer will be supported since LLVM 17, which means it is no longer possible to get the pointer level (e.g., i8* is 1 and i8*** is 3) by keeping calling Type *ty = ty -> getPointerElementType() until ty is not a pointer type. I am just wondering if there is any walk around to get to the pointer level now.


Solution

  • Unfortunately, there's no way of doing this since LLVM 16. This is because opaque pointers no longer contain their pontee type.

    If there's literally no other way of you getting the base type. I would recommend you to go back to LLVM 15 or to rewrite your system.