[funcattrs] Infer writeonly argument attribute [part 2]
authorPhilip Reames <listmail@philipreames.com>
Tue, 4 Jan 2022 16:39:51 +0000 (08:39 -0800)
committerPhilip Reames <listmail@philipreames.com>
Tue, 4 Jan 2022 17:07:54 +0000 (09:07 -0800)
commit0b09313cd53316eacbdc5e98d4ef00bef2c41d02
tree3e634a202a7d1c03b0a1c6a0610d30a19d6b3952
parent56ec762a76cbdf23c64707c45bfc9dd57f2e7abb
[funcattrs] Infer writeonly argument attribute [part 2]

This builds on the code from D114963, and extends it to handle calls both direct and indirect. With the revised code structure (from series of previously landed NFCs), this is pretty straight forward.

One thing to note is that we can not infer writeonly for arguments which might be captured. If the pointer can be read back by the caller, and then read through, we have no way to track that. This is the same restriction we have for readonly, except that we get no mileage out of the "callee can be readonly" exception since a writeonly param on a readonly function is either a) readnone or b) UB. This means we can't actually infer much unless nocapture has already been inferred.

Differential Revision: https://reviews.llvm.org/D115003
clang/test/CodeGen/arm-vfp16-arguments.c
clang/test/CodeGenCXX/wasm-args-returns.cpp
clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll
llvm/test/Other/cgscc-devirt-iteration.ll
llvm/test/Transforms/FunctionAttrs/norecurse.ll
llvm/test/Transforms/FunctionAttrs/writeonly.ll