[PATCH] D18367: Introduce llvm.load.relative intrinsic.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 11:56:05 PDT 2016


pcc created this revision.
pcc added reviewers: rafael, rjmccall.
pcc added a subscriber: llvm-commits.

This intrinsic takes two arguments, ``%ptr`` and ``%offset``. It loads
a 32-bit value from the address ``%ptr + %offset``, adds ``%ptr`` to that
value and returns it. The constant folder specifically recognizes the form of
this intrinsic and the constant initializers it may load from; if a loaded
constant initializer is known to have the form ``i32 trunc(x - %ptr)``,
the intrinsic call is folded to ``x``.

LLVM provides that the calculation of such a constant initializer will
not overflow at link time under the medium code model if ``x`` is an
``unnamed_addr`` function, however it does not provide the same for a constant
initializer folded into a function body; this intrinsic can be used to avoid
the possibility of overflows when loading from such a constant.

Depends on http://reviews.llvm.org/D17938

http://reviews.llvm.org/D18367

Files:
  docs/LangRef.rst
  include/llvm/CodeGen/Passes.h
  include/llvm/IR/Intrinsics.td
  include/llvm/InitializePasses.h
  lib/Analysis/InstructionSimplify.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGen.cpp
  lib/CodeGen/LLVMTargetMachine.cpp
  lib/CodeGen/PreISelIntrinsicLowering.cpp
  test/CodeGen/Generic/stop-after.ll
  test/Transforms/InstSimplify/load-relative-32.ll
  test/Transforms/InstSimplify/load-relative.ll
  test/Transforms/PreISelIntrinsicLowering/load-relative.ll
  tools/opt/opt.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18367.51315.patch
Type: text/x-patch
Size: 15699 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160322/e96c5e73/attachment.bin>


More information about the llvm-commits mailing list