[PATCH] D135075: [SimplifyLibCalls] Retain attributes added by Builder.CreateMem*

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 3 09:38:06 PDT 2022


arichardson added a comment.

In D135075#3830939 <https://reviews.llvm.org/D135075#3830939>, @nikic wrote:

> LGTM
>
>> This currently does not make much of a difference (only one tests is
>> affected), but it is helpful e.g. for the out-of-tree CHERI target where
>> Builder.CreateMemCpy() can add attributes other than parameter alignment.
>
> Out of interest, what attributes does it add?

CHERI has strict requirements on load/store alignment to preserve the hidden validity bits (you have to use aligned 16 byte loads/stores on CHERI-extended 64-bit architectures). This means we can't emit memcpy/memmove inline if the known alignment is only 8 bytes since 8 byte loads&stores will invalidate all validity bits. This means something like a 16 byte memcpy with 8 byte alignment has to be lowered to a memcpy() call so that it preserves validity bits if it is aligned to 16 bytes at runtime.

I added a new attribute "no_preserve_cheri_tags" that the frontend (as well as a few passes such as SLC) can use to indicate that the memory being copied will never have validity tags sets, which means we can inline the calls using smaller loads&stores.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135075/new/

https://reviews.llvm.org/D135075



More information about the llvm-commits mailing list