This is an archive of the discontinued LLVM Phabricator instance.

[IR] Add function pointer alignment to DataLayout
AbandonedPublic

Authored by miyuki on Mar 22 2018, 8:12 AM.

Details

Summary

The value tracking analysis uses function alignment to infer that the
least significant bits of function pointers are known to be zero.
Unfortunately, this is not correct for ARM targets: the least
significant bit of a function pointer stores the ARM/Thumb state
information (i.e., the LSB is set for Thumb functions and cleared for
ARM functions).

It is still desirable to be able to control the alignment of
functions' code (for example, aligning functions to cache line size
improves I-cache utilization), independently of function pointer
alignment.

This patch adds a new field to the DataLayout structure that stores
the ABI alignment of function pointers and uses it when querying the
alignment.

Diff Detail

Event Timeline

miyuki created this revision.Mar 22 2018, 8:12 AM

I am not entirely sure, if this should be added to the DataLayout class itself or to PointerAlignElem. I decided to go with the former because function pointers are only relevant to program address space (rather than each address space).

rogfer01 added inline comments.
docs/LangRef.rst
1948

Perhaps we want to clarify that if it is not specified (or it is zero) function pointers will be aligned as regular pointers ("p" above). Is my interpretation correct here?

Tracking the alignment of function pointers seems very unlikely to be beneficial in practice; I would rather just assume function pointers are always unaligned.

miyuki abandoned this revision.Apr 27 2018, 2:19 AM

Abandoning (https://reviews.llvm.org/D46110 has been committed instead)