Reapply [FunctionAttrs] Infer precise FMRB
authorNikita Popov <npopov@redhat.com>
Fri, 23 Sep 2022 11:03:59 +0000 (13:03 +0200)
committerNikita Popov <npopov@redhat.com>
Thu, 29 Sep 2022 12:02:15 +0000 (14:02 +0200)
commit412141663cfcc7883c24217bcb88780e4572543b
treedace286c853e6bdf0d847507d38754c6c2db2b8b
parente7f133191008b137aa9ef611b676ce2ec3c116a7
Reapply [FunctionAttrs] Infer precise FMRB

The previous version of the patch would incorrect convert an
existing argmemonly attribute into an inaccessiblemem_or_argmemonly
attribute.

-----

This updates checkFunctionMemoryAccess() to infer a precise
FunctionModRefBehavior, rather than an approximation split into
read/write and argmemonly.

Afterwards, we still map this back to imprecise function attributes.
This still allows us to infer some cases that we previously did not
handle, namely inaccessiblememonly and inaccessiblemem_or_argmemonly.
In practice, this means we get better memory attributes in the
presence of intrinsics like @llvm.assume.

Differential Revision: https://reviews.llvm.org/D134527
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/test/Transforms/FunctionAttrs/argmemonly.ll