Hello, LLVM devs.
I have the following IR:
%x = alloca i32, align 4
%p = alloca i32*, align 8
store i32* %x, i32** %p, align 8
Now I change module’s data layout and run InferAddressSpacePass. This turns that piece of code into
%x = alloca i32, align 4, addrspace(1)
%p = alloca i32*, align 8, addrspace(1)
store i32 addrspace(1)* %x, i32* addrspace(1)* %p, align 8
But Verifier complains that the module is invalid, saying
error: stored value and pointer type do not match
store i32 addrspace(1)* %x3, i32* addrspace(1)* %p4, align 8
I didn’t even manage to write correct IR manually in presence of addrspace().
Is it a bug, or I’m missing something?
Thanks in advance.
Gleb Popov via llvm-dev writes:
I have the following IR:
%x = alloca i32, align 4
%p = alloca i32*, align 8
store i32* %x, i32** %p, align 8
Now I change module's data layout and run InferAddressSpacePass. This turns that piece of code into
%x = alloca i32, align 4, addrspace(1)
%p = alloca i32*, align 8, addrspace(1)
store i32 addrspace(1)* %x, i32* addrspace(1)* %p, align 8
But Verifier complains that the module is invalid, saying
error: stored value and pointer type do not match
store i32 addrspace(1)* %x3, i32* addrspace(1)* %p4, align 8
I didn't even manage to write correct IR manually in presence of addrspace().
Is it a bug, or I'm missing something?
`i32* addrspace(1)*' is a pointer in addrspace(1) that points to a pointer in
addrspace(0) (zero address space is not printed). In other words, pointee type
of `p' is `i32*', while you're trying to store `i32 addrspace(1)*'. You have to
change the alloca to make it work:
%p = alloca i32 addrspace(1)*, align 8, addrspace(1)
store i32 addrspace(1)* %x, i32 addrspace(1)* addrspace(1)* %p, align 8
Gleb Popov via llvm-dev writes:
I have the following IR:
%x = alloca i32, align 4
%p = alloca i32*, align 8
store i32* %x, i32** %p, align 8
Now I change module’s data layout and run InferAddressSpacePass. This turns that piece of code into
%x = alloca i32, align 4, addrspace(1)
%p = alloca i32*, align 8, addrspace(1)
store i32 addrspace(1)* %x, i32* addrspace(1)* %p, align 8
But Verifier complains that the module is invalid, saying
error: stored value and pointer type do not match
store i32 addrspace(1)* %x3, i32* addrspace(1)* %p4, align 8
I didn’t even manage to write correct IR manually in presence of addrspace().
Is it a bug, or I’m missing something?
i32* addrspace(1)*' is a pointer in addrspace(1) that points to a pointer in addrspace(0) (zero address space is not printed). In other words, pointee type of
p’ is i32*', while you're trying to store
i32 addrspace(1)*’. You have to
change the alloca to make it work:
%p = alloca i32 addrspace(1), align 8, addrspace(1)
store i32 addrspace(1) %x, i32 addrspace(1)* addrspace(1)* %p, align 8
Ah, that’s why stars are in different places! Thanks for clearing this up.