[llvm-dev] Find the level of pointers

Cranmer, Joshua via llvm-dev llvm-dev at lists.llvm.org
Wed Sep 29 11:06:27 PDT 2021


LLVM is in the midst of converting to opaque pointers, where all pointers become a single opaque pointer type that does not indicate what the type the pointer is pointing to. Writing any new code that relies on the types that pointers point to will shortly (on the order of months) fail to work entirely.

If you’re dead-set on writing code that will work at best temporarily, you can compute the pointer level by iterating T = T->getPointerElementType() and counting how many times before you arrive at a non-pointer type.

From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Haritha Madhav C via llvm-dev
Sent: Monday, September 27, 2021 1:52
To: llvm-dev at lists.llvm.org
Subject: [llvm-dev] Find the level of pointers

Hi,

How can I find the level of the pointer variable? I need to differentiate between **i32 and ***i32. Is there any way to do this? getType() will return pointer type. But if I wanted to get 2 from **i32 and 3 from ***i32, is there a way?

Thanks,
Haritha Madhav C
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210929/c5a08d58/attachment.html>


More information about the llvm-dev mailing list