[llvm-dev] Is pointer tagging defined behavior?

Russell Wallace via llvm-dev llvm-dev at lists.llvm.org
Sat Mar 26 04:58:36 PDT 2016


Dynamic languages commonly use an implementation technique where you take a
pointer to an object (aligned on eight bytes so the lower three bits are
zero), cast to intptr_t, change the lower three bits to a tag value
indicating the type of the object, then later test the tag value, remove
the tag, cast back to a pointer and dereference the pointer.

As I understand it, the standard says this is implementation defined. Does
LLVM consider it to be defined behavior?

If so, is this still true if you write your own memory manager that
allocates chunks of memory (rounded up to 8 bytes) from a big char array?

(Assuming a mainstream platform such as x64 - I'm not talking about a
scenario where there is an unusual CPU architecture.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160326/38c28059/attachment.html>


More information about the llvm-dev mailing list