For a pointer to pointer ?How to fast get the pointee pointer?

Hi all, i am coding to analyze an IR with multi-level pointers, and i am eager to know whether there exists a way to find the pointee pointer directly, if only given an upper level pointer.

For example, in the following demo,

C code:

int i = 10;
int *p = &i;
int **pp;
*pp = &p;

IR code:

%i = alloca i32, align 4
%p = alloca i32*, align 8
%pp = alloca i32**, align 8
store i32 10, i32* %i, align 4
store i32* %i, i32** %p, align 8
%0 = bitcast i32** %p to i32*

If I know the value of pp already, Is there a fast method for me to find pointer p directly? And if not must I consider AA case here?


Best Regards,


This is a statically undecidable problem, so yes, you must consider
AA, and there can be nothing that provides an exact answer in all

There is nothing in LLVM that will help you, but folks have developed
datastructures that can give fast answers to points-to and pointed-by

Got it, thank you Daniel, Have a nice day!