[LLVMdev] Semantics of bitcast wrt removing one level of indirection from pointers
Zvonimir Rakamaric
zvonimir at cs.utah.edu
Tue Apr 1 07:32:38 PDT 2014
Hi all,
(This question is related to the one I posted yesterday titled "LLVM
is doing something a bit weird in this example (which messes up
DSA)".)
Basically, is this a valid use of bitcast:
%2 = bitcast i32** %x to i64*
%4 = load i64* %2, align 8
Note that this way we can happily load an i64 value which is in fact a
pointer without using ptrtoint, which is to me somewhat worrisome.
The semantics of bitcast says:
"Pointer (or vector of pointers) types may only be converted to other
pointer (or vector of pointers) types with the same address space
through this instruction. To convert pointers to other types, use the
inttoptr or ptrtoint instructions first."
So the example appears to be fine, but I still find it awkward that by
getting rid of one level of indirection using bitcast one can actually
implicitly get the functionality of ptrtoint. This, of course, throws
off DSA later on...
Thanks!
Cheers,
-- Zvonimir
--
http://zvonimir.info
http://soarlab.org/
More information about the llvm-dev
mailing list