[LLVMdev] Question on equivalence of pointer types

Sanjoy Das sanjoy at playingwithpointers.com
Mon Dec 8 17:12:37 PST 2014


Partially answering my own question, in general these are not
equivalent because LLVM allows for pointers in different address
spaces to have different sizes.  However, are they equivalent if
pointers in addrspace(1) have the same size as pointers in
addrspace(0)?

In other words, assuming pointers have the same size irrespective of
address spaces, is storing / loading an (not storing into / loading
from) addrspace(1)* allowed to do something semantically different
than storing / loading an addrspace(0)*?

Thanks,
-- Sanjoy

On Thu, Dec 4, 2014 at 10:09 PM, Sanjoy Das
<sanjoy at playingwithpointers.com> wrote:
> Is copy.0 semantically equivalent to copy.1 in the following example?
>
> define void @copy.0(i8 addrspace(1)* addrspace(1)* %src, i8
> addrspace(1)* addrspace(1)* %dst) {
>  entry:
>   %val = load i8 addrspace(1)* addrspace(1)* %src
>   store i8 addrspace(1)* %val, i8 addrspace(1)* addrspace(1)* %dst
>   ret void
> }
>
> define void @copy.1(i8 addrspace(1)* addrspace(1)* %src, i8
> addrspace(1)* addrspace(1)* %dst) {
>  entry:
>   %src.cast = bitcast i8 addrspace(1)* addrspace(1)* %src to i8* addrspace(1)*
>   %dst.cast = bitcast i8 addrspace(1)* addrspace(1)* %dst to i8* addrspace(1)*
>
>   %val = load i8* addrspace(1)* %src.cast
>   store i8* %val, i8* addrspace(1)* %dst.cast
>   ret void
> }
>
> -- Sanjoy



More information about the llvm-dev mailing list