Reputation: 25560
The question sounds stupid. Surely, just type:
int i = 1;
int &k = i;
But after I compile it with llvm ( optimization flag is -O0
) I have next intermediate interpretation:
%i = alloca i32, align 4 ; <i32*> [#uses=2]
%k = alloca i32*, align 8 ; <i32**> [#uses=2]
It means that i
and k
are not aliases (as I understand %k contains address of %i).
How to make an example of aliases?
Upvotes: 1
Views: 326
Reputation: 26868
Two pointers are aliased if they point to the same memory location. The concept of aliasing is only applicable for pointers - since a non-pointer value cannot point anywhere. So in your example i
can never alias anything.
If you want an aliasing example, look at this snippet:
int i = 1;
int &j = i;
int &k = i;
j
and k
are aliased.
I'm not exactly sure what you're expecting to see on the LLVM side, especially with -O0
. If you were expecting a global alias, those are unrelated and used to provide a second name to an existing global.
Upvotes: 4