[LLVMdev] [RFC] Adding functions for unaligned load/store to Support for JIT/RuntimeDyld

Alexey Samsonov
Tue, 19 Aug 2014 23:40:41 -0000

Hi,

I've noticed that certain parts of LLVM (RuntimeDyld, JIT) use unaligned
memory accesses to load/store pointers or just 32- or 64-bit integers.
Technically, this is undefined behavior, and UBSan reports errors when this
happens. Even if we believe we're running some x86-specific code (e.g.
RuntimeDyldELF::resolveX86_64Relocation) what matters for unaligned acceses
in source code is the host architecture, not the target one.

What do you think of adding

  T unaligned_load(const void *addr)
  void unaligned_store(void *addr, T value);

to support headers? We can then provide the default memcpy implementations
of these methods and, optionally, straightforward implementations for x86
hosts (and disable UBSan alignment checks for the latter).

--
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20140819/67b5bf2f/attachment.html>