[PATCH] D48905: [ADT] Guard our use of function pointers in a `PointerUnion` by a dynamic check that the pointer is actually sufficiently aligned.

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 3 16:36:30 PDT 2018


chandlerc created this revision.
chandlerc added reviewers: pcc, bogner, rsmith.
Herald added subscribers: dexonsmith, mcrosier, sanjoy.

We essentially use another bit to allow us to distinguish an embedded
function pointer from a double indirection through a well aligned
global. This makes it much easier to take advantage of the well aligned
function pointer when available, but degrade gracefully when unavailable
to an indirected function pointer.

This does come with a small cost. If folks are worried about this
runtime cost, we could just force every platform not explicitly
supported with the alignment attribute to use the indirected callback
and have no runtime overhead, but this feels a bit risky to me. Open to
suggestions.

Hopefully this fixes the reported segfault on some MacOS build bots and
with -Os and other build configurations where the alignment wasn't
actually reliable.


Repository:
  rL LLVM

https://reviews.llvm.org/D48905

Files:
  llvm/include/llvm/ADT/FunctionExtras.h
  llvm/include/llvm/Support/PointerLikeTypeTraits.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48905.154017.patch
Type: text/x-patch
Size: 7858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180703/b78d116b/attachment.bin>


More information about the llvm-commits mailing list